Re: [PATCH v2 1/4] mm: memcontrol: drop kmemcg_id and use the memcg ID for list_lru indexing

From: Gregory Price

Date: Tue Sep 22 2026 - 23:48:03 EST


On Mon, Sep 07, 2026 at 07:01:08PM +0800, Qinyun Tan wrote:
> kmemcg_id is a copy of the memcg ID assigned in memcg_online_kmem(),
> and is only used as the list_lru xarray index. With
> cgroup.memory=nokmem the assignment never happens, so every memcg
> resolves to the per-node lists. The next patch needs the index to
> work under nokmem as well, so drop the copy and use the memcg ID.
>
> The ID works just as well as the copy did: root and NULL still
> return -1 and use the per-node lists, and the ID is only released
> after the list_lru reparenting, so a stale or recycled ID can never
> reach a live list_lru entry.
>
> The early return of memcg_offline_kmem() under nokmem is dropped as
> well, so the reparenting also covers lrus that stay memcg aware
> without kmem accounting.
>
> Signed-off-by: Qinyun Tan <qinyuntan@xxxxxxxxxxxxxxxxx>

This breaks an assert in memcg_struct_check - i think you want to drop
this line as well

---

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 5d7a26c91610..fcba9eb55659 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5886,8 +5886,6 @@ static void __init memcg_struct_check(void)
private_id_objcg);
CACHELINE_ASSERT_GROUP_MEMBER(struct mem_cgroup, memcg_read_mostly,
private_id);
- CACHELINE_ASSERT_GROUP_MEMBER(struct mem_cgroup, memcg_read_mostly,
- kmemcg_id);
CACHELINE_ASSERT_GROUP_MEMBER(struct mem_cgroup, memcg_read_mostly,
oom_group);