Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: memcontrol: reclaim when shrinking memory.high below usage

When setting memory.high below usage, nothing happens until the next
charge comes along, and then it will only reclaim its own charge and not
the now potentially huge excess of the new memory.high. This can cause
groups to stay in excess of their memory.high indefinitely.

To fix that, when shrinking memory.high, kick off a reclaim cycle that
goes after the delta.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Vladimir Davydov <vdavydov@virtuozzo.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Johannes Weiner and committed by
Linus Torvalds
588083bb d9b2ddf8

+6
+6
mm/memcontrol.c
··· 4992 4992 char *buf, size_t nbytes, loff_t off) 4993 4993 { 4994 4994 struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of)); 4995 + unsigned long nr_pages; 4995 4996 unsigned long high; 4996 4997 int err; 4997 4998 ··· 5002 5001 return err; 5003 5002 5004 5003 memcg->high = high; 5004 + 5005 + nr_pages = page_counter_read(&memcg->memory); 5006 + if (nr_pages > high) 5007 + try_to_free_mem_cgroup_pages(memcg, nr_pages - high, 5008 + GFP_KERNEL, true); 5005 5009 5006 5010 memcg_wb_domain_size_changed(memcg); 5007 5011 return nbytes;