diff options
| author | Bingfang Guo <bingfangguo@tencent.com> | 2026-09-21 14:16:27 +0800 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-10-24 01:55:51 -0700 |
| commit | 8290f45995f5700b87a47b1ee8c97300dfb66dda (patch) | |
| tree | 588a41c3f3f4d7612f324fe5de5b5357fa404429 /tools/perf/scripts/python/flamegraph.py | |
| parent | 0262a5ee845c9c6b0a68ee587fffd6df01da19b5 (diff) | |
memcg: move memcg private ID refcount to objcg
The memcg private ID is used by objects that can't afford storing a whole
pointer and can outlive memcgs to track the memcg (notably swap entries).
The current design holds a refcount to the css, preventing the memcg from
being freed.
This patch unbinds the lifetime of memcgid from the memcg so it can be
freed. The idea is to move the refcount of memcgid to one of the memcg's
objcg. The objcg is stored in the global memcgid xarray instead and used
for retrieving the online memcg from it. So swapped out pages no longer
pin the dying memcg.
After the change, a memcgid can refer to a non present memcg. To handle
this situation, when trying to get the original memcg from the id, compare
the memcgid passed in with that of the memcg, and return NULL to indicate
its death if they differ. NULL checks are added for list_lru_walk_node(),
workingset_test_recent() to skip dead memcgs. For MGLRU recency test,
mem_cgroup_lruvec() will substitute NULL with root_mem_cgroup.
In the earlier patch, an extra xarray lookup was introduced in swap
uncharging path. Now that we have the objcg pointer in the function, the
extra overhead can be removed by using it for putting directly.
Link: https://lore.kernel.org/20260921-bingfangguo-memcgid-rework-v2-4-6c0637dc0edb@tencent.com
Signed-off-by: Bingfang Guo <bingfangguo@tencent.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Muchun Song <muchun.song@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Qi Zheng <qi.zheng@linux.dev>
Cc: Kairui Song <kasong@tencent.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Yuanchu Xie <yuanchu@google.com>
Cc: Wei Xu <weixugc@google.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Bingfang Guo <bfguo@icloud.com>
Diffstat (limited to 'tools/perf/scripts/python/flamegraph.py')
0 files changed, 0 insertions, 0 deletions
