[rh7,1/2] mm/memcg: fix margin computation for kmem limit.

Submitted by Andrey Ryabinin on Feb. 28, 2018, 10:36 a.m.

Details

Message ID 20180228103627.2427-1-aryabinin@virtuozzo.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Andrey Ryabinin Feb. 28, 2018, 10:36 a.m.
if kmem usage is above kmem.limit mem_cgroup_margin() we return
non-zero margin possibly leading to endless loop in try_charge().

https://jira.sw.ru/browse/PSBM-81818
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 mm/memcontrol.c | 2 ++
 1 file changed, 2 insertions(+)

Patch hide | download patch | download mbox

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index b4d61d72ccbf..d68650ad7a53 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1829,6 +1829,8 @@  static unsigned long mem_cgroup_margin(struct mem_cgroup *memcg, bool kmem)
 		limit = READ_ONCE(memcg->kmem.limit);
 		if (count <= limit)
 			margin = min(margin, limit - count);
+		else
+			margin = 0;
 	}
 
 	return margin;