[Devel] [PATCH RHEL7 COMMIT] ms/mm: memcontrol: reclaim when shrinking memory.high below usage

Konstantin Khorenko khorenko at virtuozzo.com
Wed Jun 22 05:15:13 PDT 2016


The commit is pushed to "branch-rh7-3.10.0-327.18.2.vz7.14.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.18.2.vz7.14.17
------>
commit d1074e8489380ff3087edc2ca86e88a2fdb25b05
Author: Johannes Weiner <hannes at cmpxchg.org>
Date:   Wed Jun 22 16:15:13 2016 +0400

    ms/mm: memcontrol: reclaim when shrinking memory.high below usage
    
    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.
    
    https://jira.sw.ru/browse/PSBM-48546
    
    Signed-off-by: Johannes Weiner <hannes at cmpxchg.org>
    Acked-by: Michal Hocko <mhocko at suse.com>
    Cc: Vladimir Davydov <vdavydov at virtuozzo.com>
    Cc: <stable at vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
    (cherry picked from commit 588083bb37a3cea8533c392370a554417c8f29cb)
    Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
    
    Conflicts:
    	mm/memcontrol.c
---
 mm/memcontrol.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index de7c362..1f525f2 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5314,7 +5314,7 @@ static int mem_cgroup_high_write(struct cgroup *cont, struct cftype *cft,
 				 const char *buffer)
 {
 	struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
-	unsigned long long val;
+	unsigned long long val, usage;
 	int ret;
 
 	ret = res_counter_memparse_write_strategy(buffer, &val);
@@ -5322,6 +5322,12 @@ static int mem_cgroup_high_write(struct cgroup *cont, struct cftype *cft,
 		return ret;
 
 	memcg->high = val;
+
+	usage = res_counter_read_u64(&memcg->res, RES_USAGE);
+	if (usage > val)
+		try_to_free_mem_cgroup_pages(memcg,
+					     (usage - val) >> PAGE_SHIFT,
+					     GFP_KERNEL, false);
 	return 0;
 }
 


More information about the Devel mailing list