]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
mm: memcontrol: move obj_cgroup_uncharge_pages() out of css_set_lock
authorMuchun Song <songmuchun@bytedance.com>
Tue, 29 Jun 2021 02:38:06 +0000 (19:38 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 29 Jun 2021 17:53:50 +0000 (10:53 -0700)
The css_set_lock is used to guard the list of inherited objcgs.  So there
is no need to uncharge kernel memory under css_set_lock.  Just move it out
of the lock.

Link: https://lkml.kernel.org/r/20210417043538.9793-8-songmuchun@bytedance.com
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Roman Gushchin <guro@fb.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: Xiongchun Duan <duanxiongchun@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/memcontrol.c

index c79b6926fe8356e3517dbbdec52b206252406334..f7a552eb3e9d6cc51273ea430745eca63ea235ff 100644 (file)
@@ -289,9 +289,10 @@ static void obj_cgroup_release(struct percpu_ref *ref)
        WARN_ON_ONCE(nr_bytes & (PAGE_SIZE - 1));
        nr_pages = nr_bytes >> PAGE_SHIFT;
 
-       spin_lock_irqsave(&css_set_lock, flags);
        if (nr_pages)
                obj_cgroup_uncharge_pages(objcg, nr_pages);
+
+       spin_lock_irqsave(&css_set_lock, flags);
        list_del(&objcg->list);
        spin_unlock_irqrestore(&css_set_lock, flags);