From: Shakeel Butt <shakeelb@xxxxxxxxxx> Subject: 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@xxxxxxxxxx Signed-off-by: Shakeel Butt <shakeelb@xxxxxxxxxx> Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx> Acked-by: Michal Hocko <mhocko@xxxxxxxx> Cc: Greg Thelen <gthelen@xxxxxxxxxx> Cc: Vladimir Davydov <vdavydov.dev@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memcontrol.c | 7 +++++++ 1 file changed, 7 insertions(+) diff -puN mm/memcontrol.c~mm-memcontrol-drain-stocks-on-resize-limit mm/memcontrol.c --- a/mm/memcontrol.c~mm-memcontrol-drain-stocks-on-resize-limit +++ a/mm/memcontrol.c @@ -2450,6 +2450,7 @@ static int mem_cgroup_resize_max(struct 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 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; _ -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html