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 <aryabi...@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

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to