From: Johannes Weiner <hannes@cmpxchg.org>
To: Dave Chinner <dgc@kernel.org>
Cc: Kaitao Cheng <kaitao.cheng@linux.dev>,
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, 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: Fri, 6 Nov 2026 09:06:00 -0500 [thread overview]
Message-ID: <au3eyCrHiuhbJx3u@cmpxchg.org> (raw)
In-Reply-To: <aupITfr9pBKPrU20@dread>
On Wed, Nov 04, 2026 at 07:47:09AM +1100, Dave Chinner wrote:
> 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.
Grr, Kaitao you dropped the wrong thing that I thought had merit in my
proposal...
Dave, would you mind taking a look at my patch at
https://lore.kernel.org/all/auJkvb-Lq0M5Enkz@cmpxchg.org/?
Ignore zswap for a second. I know it has problems. Most of it stems
from the fact that we rely on the swap locking and do none of our own
locking/lifetime on the zswap entry. As a result we work around it in
odd ways. Sorry, you didn't ask :-) That's worth revisiting, although
it's likely more invasive work.
The observation that led to the patch above was a much simpler one:
since we now have the caller-locked __list_lru_del() anyway, the only
difference between that and the list_lru_isolate* is the
accounting. The patch is about one thing: removing the isolate helpers
entirely. There is then simply one tool for caller-locked list
unlinking, __list_lru_del(). It removes an avoidable distinction,
shrinks the API surface, makes it harder to screw up.
The zswap weirdness made me look at list_lru. Consider it a stress
test from idiotic code :-) But I would propose the list_lru
simplification for its own sake, regardless of what we do with zswap.
prev parent reply other threads:[~2026-11-06 14:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 4:50 Kaitao Cheng
2026-11-03 20:47 ` Dave Chinner
2026-11-06 14:06 ` Johannes Weiner [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=au3eyCrHiuhbJx3u@cmpxchg.org \
--to=hannes@cmpxchg.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=dgc@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gfs2@lists.linux.dev \
--cc=gregkh@linuxfoundation.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
all inboxes | Powered by JetHome®