[RHEL7,COMMIT] mm/memcg: fix margin computation for kmem limit.

Submitted by Konstantin Khorenko on March 1, 2018, 8:25 a.m.

Details

Message ID 201803010825.w218P27n007798@finist_ce7.work
State New
Series "Series without cover letter"
Headers show

Commit Message

Konstantin Khorenko March 1, 2018, 8:25 a.m.
The commit is pushed to "branch-rh7-3.10.0-693.17.1.vz7.45.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.17.1.vz7.45.6
------>
commit 057df72c6cf1550ba1fbd50f05c3d64577b2b0f2
Author: Andrey Ryabinin <aryabinin@virtuozzo.com>
Date:   Thu Mar 1 11:25:02 2018 +0300

    mm/memcg: fix margin computation for kmem limit.
    
    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;