[Devel] [PATCH RHEL7 COMMIT] mm: Move memcg_uncharge_kmem() to bottom of __memcg_uncharge_slab()

Konstantin Khorenko khorenko at virtuozzo.com
Thu May 7 21:30:06 MSK 2020


The commit is pushed to "branch-rh7-3.10.0-1127.vz7.150.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.vz7.150.8
------>
commit e6b9d2fd9553518998e59e720798baeb56c80f0b
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Thu May 7 21:30:06 2020 +0300

    mm: Move memcg_uncharge_kmem() to bottom of __memcg_uncharge_slab()
    
    memcg_uncharge_kmem() potentially may put last css counter. After
    that we can't touch memcg memory anymore.
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index b4484567ce82f..797cb8e6df6d7 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3574,7 +3574,6 @@ void __memcg_uncharge_slab(struct kmem_cache *s, unsigned int nr_pages)
 	VM_BUG_ON(is_root_cache(s));
 	memcg = s->memcg_params.memcg;
 
-	memcg_uncharge_kmem(memcg, nr_pages);
 	if (s->flags & SLAB_RECLAIM_ACCOUNT) {
 		page_counter_uncharge(&memcg->dcache, nr_pages);
 		idx = MEM_CGROUP_STAT_SLAB_RECLAIMABLE;
@@ -3583,6 +3582,7 @@ void __memcg_uncharge_slab(struct kmem_cache *s, unsigned int nr_pages)
 		idx = MEM_CGROUP_STAT_SLAB_UNRECLAIMABLE;
 		this_cpu_sub(memcg->stat->count[idx], nr_pages);
 	}
+	memcg_uncharge_kmem(memcg, nr_pages);
 }
 
 /*


More information about the Devel mailing list