Skip to content

Commit 566d150

Browse files
hnazDinh Nguyen
authored andcommitted
mm: memcontrol: reclaim when shrinking memory.high below usage
[ Upstream commit 588083b ] 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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 647750d commit 566d150

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
@@ -5295,6 +5295,7 @@ static ssize_t memory_high_write(struct kernfs_open_file *of,
52955295
char *buf, size_t nbytes, loff_t off)
52965296
{
52975297
struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of));
5298+
unsigned long nr_pages;
52985299
unsigned long high;
52995300
int err;
53005301

@@ -5305,6 +5306,11 @@ static ssize_t memory_high_write(struct kernfs_open_file *of,
53055306

53065307
memcg->high = high;
53075308

5309+
nr_pages = page_counter_read(&memcg->memory);
5310+
if (nr_pages > high)
5311+
try_to_free_mem_cgroup_pages(memcg, nr_pages - high,
5312+
GFP_KERNEL, true);
5313+
53085314
return nbytes;
53095315
}
53105316

0 commit comments

Comments
 (0)