Commit bb4a7ea2 authored by Shakeel Butt's avatar Shakeel Butt Committed by Linus Torvalds

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.comSigned-off-by: default avatarShakeel Butt <shakeelb@google.com>
Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Acked-by: default avatarMichal Hocko <mhocko@suse.com>
Cc: Greg Thelen <gthelen@google.com>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8dd53fd3
...@@ -2450,6 +2450,7 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg, ...@@ -2450,6 +2450,7 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg,
unsigned long max, bool memsw) unsigned long max, bool memsw)
{ {
bool enlarge = false; bool enlarge = false;
bool drained = false;
int ret; int ret;
bool limits_invariant; bool limits_invariant;
struct page_counter *counter = memsw ? &memcg->memsw : &memcg->memory; struct page_counter *counter = memsw ? &memcg->memsw : &memcg->memory;
...@@ -2480,6 +2481,12 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg, ...@@ -2480,6 +2481,12 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg,
if (!ret) if (!ret)
break; break;
if (!drained) {
drain_all_stock(memcg);
drained = true;
continue;
}
if (!try_to_free_mem_cgroup_pages(memcg, 1, if (!try_to_free_mem_cgroup_pages(memcg, 1,
GFP_KERNEL, !memsw)) { GFP_KERNEL, !memsw)) {
ret = -EBUSY; ret = -EBUSY;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment