From: Dave Chinner <dgc@kernel.org>
To: Kaitao Cheng <kaitao.cheng@linux.dev>
Cc: gregkh@linuxfoundation.org, arve@android.com, tkjos@android.com,
brauner@kernel.org, cmllamas@google.com, aliceryhl@google.com,
nat@pixelcluster.dev, arunpravin.paneerselvam@amd.com,
maarten.lankhorst@linux.intel.com, mripard@kernel.org,
tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch,
viro@zeniv.linux.org.uk, agruenba@redhat.com, trondmy@kernel.org,
anna@kernel.org, cel@kernel.org, jlayton@kernel.org,
cem@kernel.org, akpm@linux-foundation.org, david@fromorbit.com,
david@kernel.org, hughd@google.com, hannes@cmpxchg.org,
yosry@kernel.org, nphamcs@gmail.com, matthew.auld@intel.com,
matthew.brost@intel.com, thomas.hellstrom@linux.intel.com,
jack@suse.cz, neil@brown.name, okorniev@redhat.com,
Dai.Ngo@oracle.com, tom@talpey.com, qi.zheng@linux.dev,
roman.gushchin@linux.dev, muchun.song@linux.dev, ziy@nvidia.com,
baolin.wang@linux.alibaba.com, liam@infradead.org,
nico.pache@linux.dev, ryan.roberts@arm.com, dev.jain@arm.com,
baohua@kernel.org, lance.yang@linux.dev, usama.arif@linux.dev,
kas@kernel.org, mhocko@kernel.org, shakeel.butt@linux.dev,
ljs@kernel.org, kasong@tencent.com, axelrasmussen@google.com,
yuanchu@google.com, weixugc@google.com, baoquan.he@linux.dev,
chengming.zhou@linux.dev, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org,
gfs2@lists.linux.dev, linux-nfs@vger.kernel.org,
linux-xfs@vger.kernel.org, linux-mm@kvack.org,
Kaitao Cheng <chengkaitao@kylinos.cn>
Subject: Re: [PATCH] mm/list_lru: Account node removals in isolation helpers
Date: Wed, 4 Nov 2026 07:47:09 +1100 [thread overview]
Message-ID: <aupITfr9pBKPrU20@dread> (raw)
In-Reply-To: <20261103045053.59548-1-kaitao.cheng@linux.dev>
On Tue, Nov 03, 2026 at 12:50:53PM +0800, Kaitao Cheng wrote:
> From: Kaitao Cheng <chengkaitao@kylinos.cn>
>
> Successful writeback calls zswap_entry_free(), which removes the entry
> from the LRU and decrements both the sublist and node item counts.
> shrink_memcg_cb() then returns LRU_REMOVED_RETRY, causing the LRU walker
> to decrement the node count again.
>
> The affected call path before this change is:
>
> __list_lru_walk_one()
> shrink_memcg_cb()
> zswap_writeback_entry()
> zswap_entry_free()
> zswap_lru_del()
> list_lru_del()
> __list_lru_del()
> atomic_long_dec() /* first node count decrement */
> return LRU_REMOVED_RETRY
> atomic_long_dec() /* second node count decrement */
That's a bug in the zswap code. You shouldn't be calling
list_lru_del() from __list_lru_walk_one() context.
Walker callbacks are supposed to use list_lru_isolate() or
list_lru_isolate_move() to remove the item from the LRU under the
lru lock. i.e. the walk and remove are a single atomic operation,
accounted by the walker infrastructure.
LRU_REMOVED_RETRY is for walkers that need to do work -after- the
item has been removed from the LRU (e.g. reclaim work that can't run
under the lru lock). i.e. the pattern for the callback code is
remove-unlock-reclaim-LRU_REMOVED_RETRY.
What the zswap code is doing is
unlock-reclaim-lock-remove-unlock-LRU_REMOVED_RETRY. That's
problematic, as we can have concurrent walkers, and so it's possible
that two shrinker invocations try to remove the same item at the
same time....
.... oh, what a nasty hack.
The zswap code is doing a list_move_tail() on the LRU object to
rotate it to the end of the LRU list before dropping the LRU lock,
in the hope that a concurrent scanner won't trip over it. That
doesn't fix anything...
> During the mailing list discussion, Johannes Weiner suggested making
> users of the isolation interface responsible for maintaining the item
> counts, rather than having the walker decrement the node count based
> on the callback's return value.
urk. How is smearing the LRU NUMA abstraction into all the isolation
interfaces an improvement?
It seems to me that that this LRU hacking is all because of this:
* 2. Usually, objects are taken off the LRU for reclaim. In
* this case this isn't possible, because if reclaim fails
* for whatever reason, we have no means of knowing if the
* entry is alive to put it back on the LRU.
And so to work around this inability of zswap to handle failure
sanely, the LRU list the reclaim code is being abused. And now the
abuse of the lru list code is triggering problems with the LRU
infrastructure, the suggestion is to push internal LRU structures
into all LRU list walkers to allow racy (and IMO broken) walker
behaviour?
I'd much prefer the zswap code get fixed than to have to modify a
dozen other subsystems to enable zswap to work around broken reclaim
code...
-Dave.
--
Dave Chinner
dgc@kernel.org
prev parent reply other threads:[~2026-11-03 20:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 4:50 [PATCH] mm/list_lru: Account node removals in isolation helpers Kaitao Cheng
2026-11-03 20:47 ` Dave Chinner [this message]
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=aupITfr9pBKPrU20@dread \
--to=dgc@kernel.org \
--cc=Dai.Ngo@oracle.com \
--cc=agruenba@redhat.com \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=aliceryhl@google.com \
--cc=anna@kernel.org \
--cc=arunpravin.paneerselvam@amd.com \
--cc=arve@android.com \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=baoquan.he@linux.dev \
--cc=brauner@kernel.org \
--cc=cel@kernel.org \
--cc=cem@kernel.org \
--cc=chengkaitao@kylinos.cn \
--cc=chengming.zhou@linux.dev \
--cc=cmllamas@google.com \
--cc=david@fromorbit.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gfs2@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=kaitao.cheng@linux.dev \
--cc=kas@kernel.org \
--cc=kasong@tencent.com \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=ljs@kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.auld@intel.com \
--cc=matthew.brost@intel.com \
--cc=mhocko@kernel.org \
--cc=mripard@kernel.org \
--cc=muchun.song@linux.dev \
--cc=nat@pixelcluster.dev \
--cc=neil@brown.name \
--cc=nico.pache@linux.dev \
--cc=nphamcs@gmail.com \
--cc=okorniev@redhat.com \
--cc=qi.zheng@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=ryan.roberts@arm.com \
--cc=shakeel.butt@linux.dev \
--cc=simona@ffwll.ch \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tkjos@android.com \
--cc=tom@talpey.com \
--cc=trondmy@kernel.org \
--cc=tzimmermann@suse.de \
--cc=usama.arif@linux.dev \
--cc=viro@zeniv.linux.org.uk \
--cc=weixugc@google.com \
--cc=yosry@kernel.org \
--cc=yuanchu@google.com \
--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