Linux cgroups development
 help / color / mirror / Atom feed
From: Qinyun Tan <qinyuntan@linux.alibaba.com>
To: Kairui Song <ryncsn@gmail.com>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Michal Hocko" <mhocko@kernel.org>,
	"Roman Gushchin" <roman.gushchin@linux.dev>,
	"Shakeel Butt" <shakeel.butt@linux.dev>,
	"Muchun Song" <muchun.song@linux.dev>,
	"Michal Koutný" <mkoutny@suse.com>,
	"David Hildenbrand" <david@kernel.org>, "Zi Yan" <ziy@nvidia.com>,
	"Baolin Wang" <baolin.wang@linux.alibaba.com>,
	"Usama Arif" <usama.arif@linux.dev>,
	"Dave Chinner" <david@fromorbit.com>,
	"Qi Zheng" <qi.zheng@linux.dev>, "Yosry Ahmed" <yosry@kernel.org>,
	"Nhat Pham" <nphamcs@gmail.com>,
	"Chengming Zhou" <chengming.zhou@linux.dev>,
	"Xunlei Pang" <xlpang@linux.alibaba.com>,
	cgroups@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/4] mm: memcontrol: drop kmemcg_id and use mem_cgroup_id() for list_lru indexing
Date: Thu, 8 Oct 2026 17:39:26 +0800	[thread overview]
Message-ID: <01f89ece-9d46-47f2-b660-d32ab5d32923@linux.alibaba.com> (raw)
In-Reply-To: <CAMgjq7DkLi7aPLRyGv__f6NLPkRHY=0Fw0kLEdevnoTFpqsbzw@mail.gmail.com>



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


  reply	other threads:[~2026-10-08  9:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10  8:07 [PATCH v3 0/4] mm: restore per-memcg reclaim for NONSLAB shrinkers under nokmem Qinyun Tan
2026-09-10  8:07 ` [PATCH v3 1/4] mm: memcontrol: drop kmemcg_id and use mem_cgroup_id() for list_lru indexing Qinyun Tan
2026-09-26 20:29   ` Kairui Song
2026-10-08  9:39     ` Qinyun Tan [this message]
2026-09-10  8:07 ` [PATCH v3 2/4] mm: list_lru: keep per-memcg lists with nokmem for NONSLAB-backed lrus Qinyun Tan
2026-09-10  8:07 ` [PATCH v3 3/4] mm: thp: restore SHRINKER_NONSLAB on the deferred split shrinker Qinyun Tan
2026-09-10  8:07 ` [PATCH v3 4/4] mm: zswap: mark the zswap shrinker SHRINKER_NONSLAB Qinyun Tan
2026-09-10 22:34 ` [PATCH v3 0/4] mm: restore per-memcg reclaim for NONSLAB shrinkers under nokmem Andrew Morton
2026-09-22  9:52   ` Qinyun Tan
2026-09-23  1:35 ` Andrew Morton
2026-09-23 12:40   ` Michal Koutný

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=01f89ece-9d46-47f2-b660-d32ab5d32923@linux.alibaba.com \
    --to=qinyuntan@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=cgroups@vger.kernel.org \
    --cc=chengming.zhou@linux.dev \
    --cc=david@fromorbit.com \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=mkoutny@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=nphamcs@gmail.com \
    --cc=qi.zheng@linux.dev \
    --cc=roman.gushchin@linux.dev \
    --cc=ryncsn@gmail.com \
    --cc=shakeel.butt@linux.dev \
    --cc=usama.arif@linux.dev \
    --cc=xlpang@linux.alibaba.com \
    --cc=yosry@kernel.org \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox