aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2016-03-17 17:20:25 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-03-17 18:09:34 -0400
commit588083bb37a3cea8533c392370a554417c8f29cb (patch)
treec2ae9e34d17c670f40a1748a086f0709449900a1 /mm/memcontrol.c
parentd9b2ddf8078f743729a054362ad96be076f224af (diff)
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>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 8615b066b642..f7c9b4cbdf01 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4992,6 +4992,7 @@ static ssize_t memory_high_write(struct kernfs_open_file *of,
4992 char *buf, size_t nbytes, loff_t off) 4992 char *buf, size_t nbytes, loff_t off)
4993{ 4993{
4994 struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of)); 4994 struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of));
4995 unsigned long nr_pages;
4995 unsigned long high; 4996 unsigned long high;
4996 int err; 4997 int err;
4997 4998
@@ -5002,6 +5003,11 @@ static ssize_t memory_high_write(struct kernfs_open_file *of,
5002 5003
5003 memcg->high = high; 5004 memcg->high = high;
5004 5005
5006 nr_pages = page_counter_read(&memcg->memory);
5007 if (nr_pages > high)
5008 try_to_free_mem_cgroup_pages(memcg, nr_pages - high,
5009 GFP_KERNEL, true);
5010
5005 memcg_wb_domain_size_changed(memcg); 5011 memcg_wb_domain_size_changed(memcg);
5006 return nbytes; 5012 return nbytes;
5007} 5013}