Skip to content

Commit 588083b

Browse files
hnaztorvalds
authored andcommitted
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 <[email protected]> Acked-by: Michal Hocko <[email protected]> Cc: Vladimir Davydov <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent d9b2ddf commit 588083b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

mm/memcontrol.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4992,6 +4992,7 @@ static ssize_t memory_high_write(struct kernfs_open_file *of,
49924992
char *buf, size_t nbytes, loff_t off)
49934993
{
49944994
struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of));
4995+
unsigned long nr_pages;
49954996
unsigned long high;
49964997
int err;
49974998

@@ -5002,6 +5003,11 @@ static ssize_t memory_high_write(struct kernfs_open_file *of,
50025003

50035004
memcg->high = high;
50045005

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+
50055011
memcg_wb_domain_size_changed(memcg);
50065012
return nbytes;
50075013
}

0 commit comments

Comments
 (0)