From d12c60f64cf8c768fddfd848eaf7ee57a13f18b1 Mon Sep 17 00:00:00 2001 From: Junaid Shahid Date: Thu, 7 Jun 2018 17:07:31 -0700 Subject: mm: memcontrol: drain memcg stock on force_empty The per-cpu memcg stock can retain a charge of upto 32 pages. On a machine with large number of cpus, this can amount to a decent amount of memory. Additionally force_empty interface might be triggering unneeded memcg reclaims. Link: http://lkml.kernel.org/r/20180507201651.165879-1-shakeelb@google.com Signed-off-by: Junaid Shahid Signed-off-by: Shakeel Butt Acked-by: Michal Hocko Cc: Greg Thelen Cc: Johannes Weiner Cc: Vladimir Davydov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/memcontrol.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mm') diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 18dcdac0b158..e6de0d6a3a8d 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2610,6 +2610,9 @@ static int mem_cgroup_force_empty(struct mem_cgroup *memcg) /* we call try-to-free pages for make this cgroup empty */ lru_add_drain_all(); + + drain_all_stock(memcg); + /* try to free all pages in this cgroup */ while (nr_retries && page_counter_read(&memcg->memory)) { int progress; -- cgit v1.2.3-70-g09d2