[Devel] [PATCH RHEL7 COMMIT] mm: memcg: use proper memcg in limit bypass

Vladimir Davydov vdavydov at virtuozzo.com
Tue Sep 8 08:31:00 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-229.7.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.6.8
------>
commit c9fa84db5ad62385ca5327aebb22f115afe98d91
Author: Johannes Weiner <hannes at cmpxchg.org>
Date:   Tue Sep 8 19:31:00 2015 +0400

    mm: memcg: use proper memcg in limit bypass
    
    Commit 84235de394d9 ("fs: buffer: move allocation failure loop into the
    allocator") allowed __GFP_NOFAIL allocations to bypass the limit if they
    fail to reclaim enough memory for the charge.  But because the main test
    case was on a 3.2-based system, the patch missed the fact that on newer
    kernels the charge function needs to return root_mem_cgroup when
    bypassing the limit, and not NULL.  This will corrupt whatever memory is
    at NULL + percpu pointer offset.  Fix this quickly before problems are
    reported.
    
    Signed-off-by: Johannes Weiner <hannes at cmpxchg.org>
    Acked-by: Michal Hocko <mhocko at suse.cz>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
    (cherry picked from commit 3168ecbe1c04ec3feb7cb42388a17d7f047fe1a2)
    Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 mm/memcontrol.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 1433526f6bda..4bf6d3e736bf 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2967,10 +2967,10 @@ done:
 	*ptr = memcg;
 	return 0;
 nomem:
-	*ptr = NULL;
-	if (gfp_mask & __GFP_NOFAIL)
-		return 0;
-	return -ENOMEM;
+	if (!(gfp_mask & __GFP_NOFAIL)) {
+		*ptr = NULL;
+		return -ENOMEM;
+	}
 bypass:
 	*ptr = root_mem_cgroup;
 	return -EINTR;



More information about the Devel mailing list