[Devel] [PATCH rh7 6/7] mm/memcg: don't release memcg->css too early

Andrey Ryabinin aryabinin at virtuozzo.com
Fri Mar 31 06:51:10 PDT 2017


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>
---
 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;
 }
 
-- 
2.10.2



More information about the Devel mailing list