Skip to contentSkip to conversation

mm/memcontrol.c: fix the margin computation in mem_cgroup_margin()

PATCH New [email protected] 1 participant 1 message May 27, 2016

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 17/19 mm/memcontrol.c: fix the margin computation in mem_cgroup_margin()

From: Li RongQing <[email protected]>
Subject: 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).

---

 mm/memcontrol.c |    2 ++
 1 file changed, 2 insertions(+)
mm/memcontrol.c renamed from mm/memcontrol.c~mm-memcontrol-fix-the-margin-computation-in-mem_cgroup_margin +2 -0
diff -puN mm/memcontrol.c~mm-memcontrol-fix-the-margin-computation-in-mem_cgroup_margin mm/memcontrol.c
@@ -1108,6 +1108,8 @@ static unsigned long mem_cgroup_margin(s
 		limit = READ_ONCE(memcg->memsw.limit);
 		if (count <= limit)
 			margin = min(margin, limit - count);
+		else
+			margin = 0;
 	}
 
 	return margin;

_