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

Submitted by Konstantin Khorenko on May 7, 2020, 6:30 p.m.

Details

Message ID 202005071830.047IU683007667@finist-ce7.sw.ru
State New
Series "mm: Move memcg_uncharge_kmem() to bottom of __memcg_uncharge_slab()"
Headers show

Commit Message

Konstantin Khorenko May 7, 2020, 6:30 p.m.
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@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@virtuozzo.com>
---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

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);
 }
 
 /*