mirror of
https://github.com/torvalds/linux.git
synced 2026-10-07 05:31:08 -04:00
mm/memcontrol.c: fix the margin computation in mem_cgroup_margin()
mem_cgroup_margin() might return (memory.limit - memory_count) when the memsw.limit is in excess. This doesn't happen usually because we do not allow excess on hard limits and (memory.limit <= memsw.limit), but __GFP_NOFAIL charges can force the charge and cause the excess when no memory is really swappable (swap is full or no anonymous memory is left). [[email protected]: rewrote changelog] Link: http://lkml.kernel.org/r/[email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Li RongQing <[email protected]> Acked-by: Vladimir Davydov <[email protected]> Acked-by: Michal Hocko <[email protected]> Cc: Johannes Weiner <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
1 parent
badbda53e5
commit
cbedbac3e6
1 file changed
+2
@@ -1108,6 +1108,8 @@ static unsigned long mem_cgroup_margin(struct mem_cgroup *memcg)
|
||||
limit = READ_ONCE(memcg->memsw.limit);
|
||||
if (count <= limit)
|
||||
margin = min(margin, limit - count);
|
||||
else
|
||||
margin = 0;
|
||||
}
|
||||
|
||||
return margin;
|
||||
|
||||
Reference in new issue
Block a user