This is a note to let you know that I've just added the patch titled mm: memcontrol: fix get_active_memcg return value to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: mm-memcontrol-fix-get_active_memcg-return-value.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 1685bde6b9af55923180a76152036c7fb7176db0 Mon Sep 17 00:00:00 2001 From: Muchun Song <songmuchun@xxxxxxxxxxxxx> Date: Wed, 24 Feb 2021 12:04:22 -0800 Subject: mm: memcontrol: fix get_active_memcg return value From: Muchun Song <songmuchun@xxxxxxxxxxxxx> commit 1685bde6b9af55923180a76152036c7fb7176db0 upstream. We use a global percpu int_active_memcg variable to store the remote memcg when we are in the interrupt context. But get_active_memcg always return the current->active_memcg or root_mem_cgroup. The remote memcg (set in the interrupt context) is ignored. This is not what we want. So fix it. Link: https://lkml.kernel.org/r/20210223091101.42150-1-songmuchun@xxxxxxxxxxxxx Fixes: 37d5985c003d ("mm: kmem: prepare remote memcg charging infra for interrupt contexts") Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx> Reviewed-by: Shakeel Butt <shakeelb@xxxxxxxxxx> Reviewed-by: Roman Gushchin <guro@xxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Cc: Vladimir Davydov <vdavydov.dev@xxxxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- mm/memcontrol.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1083,13 +1083,9 @@ static __always_inline struct mem_cgroup rcu_read_lock(); memcg = active_memcg(); - if (memcg) { - /* current->active_memcg must hold a ref. */ - if (WARN_ON_ONCE(!css_tryget(&memcg->css))) - memcg = root_mem_cgroup; - else - memcg = current->active_memcg; - } + /* remote memcg must hold a ref. */ + if (memcg && WARN_ON_ONCE(!css_tryget(&memcg->css))) + memcg = root_mem_cgroup; rcu_read_unlock(); return memcg; Patches currently in stable-queue which might be from songmuchun@xxxxxxxxxxxxx are queue-5.10/mm-memcontrol-fix-slub-memory-accounting.patch queue-5.10/mm-memcontrol-fix-nr_anon_thps-accounting-in-charge-.patch queue-5.10/mm-memcontrol-fix-get_active_memcg-return-value.patch queue-5.10/mm-memcontrol-fix-swap-undercounting-in-cgroup2.patch