[Devel] [PATCH RHEL7 COMMIT] mm/memcg: don't release memcg->css too early

Konstantin Khorenko khorenko at virtuozzo.com
Fri Mar 31 08:13:19 PDT 2017


The commit is pushed to "branch-rh7-3.10.0-514.10.2.vz7.29.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.10.2.vz7.29.9
------>
commit 34ce21ef4c667a7229a1d42634d68f8298a5321f
Author: Andrey Ryabinin <aryabinin at virtuozzo.com>
Date:   Fri Mar 31 19:13:19 2017 +0400

    mm/memcg: don't release memcg->css too early
    
    We can put css only after assigning memcg to pc->mem_cgroup:
    	pc->mem_cgroup = memcg;
    
    https://jira.sw.ru/browse/PSBM-62827
    Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
    
    Note: mainstream has already reworked this code, so not affected.
---
 mm/memcontrol.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 4e1dbbb..1999dff 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3387,10 +3387,10 @@ __memcg_kmem_newpage_charge(struct page *page, gfp_t gfp, int order)
 	}
 
 	ret = memcg_charge_kmem(memcg, gfp, 1 << order);
-	css_put(&memcg->css);
-
-	if (ret)
+	if (ret) {
+		css_put(&memcg->css);
 		return false;
+	}
 
 	pc = lookup_page_cgroup(page);
 	pc->mem_cgroup = memcg;
@@ -3398,6 +3398,7 @@ __memcg_kmem_newpage_charge(struct page *page, gfp_t gfp, int order)
 
 	__SetPageKmemcg(page);
 
+	css_put(&memcg->css);
 	return true;
 }
 


More information about the Devel mailing list