mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-01 22:54:01 +00:00
mm: memcontrol: fix get_active_memcg return value
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@bytedance.com
Fixes: 37d5985c00
("mm: kmem: prepare remote memcg charging infra for interrupt contexts")
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Reviewed-by: Roman Gushchin <guro@fb.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
cae3af62b3
commit
1685bde6b9
1 changed files with 3 additions and 7 deletions
|
@ -1061,13 +1061,9 @@ static __always_inline struct mem_cgroup *get_active_memcg(void)
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
memcg = active_memcg();
|
memcg = active_memcg();
|
||||||
if (memcg) {
|
/* remote memcg must hold a ref. */
|
||||||
/* current->active_memcg must hold a ref. */
|
if (memcg && WARN_ON_ONCE(!css_tryget(&memcg->css)))
|
||||||
if (WARN_ON_ONCE(!css_tryget(&memcg->css)))
|
|
||||||
memcg = root_mem_cgroup;
|
memcg = root_mem_cgroup;
|
||||||
else
|
|
||||||
memcg = current->active_memcg;
|
|
||||||
}
|
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
|
|
||||||
return memcg;
|
return memcg;
|
||||||
|
|
Loading…
Reference in a new issue