summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorShakeel Butt <shakeelb@google.com>2018-06-07 17:07:27 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2018-06-07 17:34:36 -0700
commitbb4a7ea2b1449722cec9d787dca5a74ca36e8eeb (patch)
tree3d4eb1f9a420f3ea5a4b62ad013c42870f99b0d8 /mm
parent8dd53fd3b702c12050ec5ddd07b56f8c4608ebea (diff)
downloadop-kernel-dev-bb4a7ea2b1449722cec9d787dca5a74ca36e8eeb.zip
op-kernel-dev-bb4a7ea2b1449722cec9d787dca5a74ca36e8eeb.tar.gz
mm: memcontrol: drain stocks on resize limit
Resizing the memcg limit for cgroup-v2 drains the stocks before triggering the memcg reclaim. Do the same for cgroup-v1 to make the behavior consistent. Link: http://lkml.kernel.org/r/20180504205548.110696-1-shakeelb@google.com Signed-off-by: Shakeel Butt <shakeelb@google.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Greg Thelen <gthelen@google.com> Cc: Vladimir Davydov <vdavydov.dev@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memcontrol.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 847a775..18dcdac 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2450,6 +2450,7 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg,
unsigned long max, bool memsw)
{
bool enlarge = false;
+ bool drained = false;
int ret;
bool limits_invariant;
struct page_counter *counter = memsw ? &memcg->memsw : &memcg->memory;
@@ -2480,6 +2481,12 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg,
if (!ret)
break;
+ if (!drained) {
+ drain_all_stock(memcg);
+ drained = true;
+ continue;
+ }
+
if (!try_to_free_mem_cgroup_pages(memcg, 1,
GFP_KERNEL, !memsw)) {
ret = -EBUSY;
OpenPOWER on IntegriCloud