Re: [PATCH v3 1/4] mm: memcontrol: drop kmemcg_id and use mem_cgroup_id() for list_lru indexing
From: Qinyun Tan
Date: Thu Oct 08 2026 - 05:40:22 EST
On 9/27/26 4:29 AM, Kairui Song wrote:
>
> Hi Qinyun
>
> With this commit, my arm64 VM hangs at every boot with a
> 100%-reproducible infinite loop in xas_find(), driven by
> the dcache shrinker during the first remount of the root filesystem.
> Reverting this fixes the issue:
>
> CPU: 2 UID: 0 PID: 579 Comm: mount Not tainted
> 7.3.0-rc4.orig-00725-g09d9672a5d4f #33 PREEMPT(full)
> pc : xas_find+0x184/0x1c8
> lr : xas_find+0x6c/0x1c8
> Call trace:
> xas_find+0x184/0x1c8
> xa_find_after+0x88/0x120
> list_lru_walk_node+0xc0/0x2a0
> shrink_dcache_sb+0x80/0x130
> reconfigure_super+0xc0/0x1f8
> vfs_fsconfig_locked+0xa8/0x120
> __arm64_sys_fsconfig+0x280/0x33c
>
> Just for reference, this also fixed it:
>
> diff --git a/mm/list_lru.c b/mm/list_lru.c
> index 7dbb6125cb1d..42c48c3b9235 100644
> --- a/mm/list_lru.c
> +++ b/mm/list_lru.c
> @@ -427,13 +427,13 @@ unsigned long list_lru_walk_node(struct list_lru
> *lru, int nid,
> unsigned long index;
>
> xa_for_each(&lru->xa, index, mlru) {
> - rcu_read_lock();
> - memcg = mem_cgroup_from_private_id(index);
> - if (!memcg || !mem_cgroup_tryget(memcg)) {
> - rcu_read_unlock();
> + memcg = mem_cgroup_get_from_id(index);
> + if (!memcg)
> continue;
> - }
> - rcu_read_unlock();
> isolated += __list_lru_walk_one(lru, nid, memcg,
> isolate, cb_arg,
> nr_to_walk, false);
>
> ===
>
> And BTW cgroup ID lookups seem much heavier, not sure about the
> performance impact.
Hi Kairui,
Thanks for tracking this down. I missed the reverse lookup in
list_lru_walk_node() when switching to cgroup IDs. Your change fixes
that mismatch.
There is a catch with mem_cgroup_get_from_id(), though: it calls
cgroup_get_from_id(), which only looks up cgroups visible in the
current task's cgroup namespace. Here we need to walk all memcgs
on the LRU, including those outside that namespace, so we need
a lookup without that restriction.
Thanks,
Qinyun Tan