From: Andrew Morton <akpm@linux-foundation.org>
To: Qian Xiao <heyheyco@gmail.com>
Cc: Matthew Wilcox <willy@infradead.org>,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Krystian Kaniewski <krystianmkaniewski@gmail.com>
Subject: Re: [PATCH v3] xarray: fix index jumping backwards in xas_find_marked()
Date: Wed, 2 Dec 2026 17:06:44 -0800 [thread overview]
Message-ID: <20261202170644.8b79f3de9e4e9c1df1b85e0f@linux-foundation.org> (raw)
In-Reply-To: <20261129235255.848478-1-heyheyco@gmail.com>
On Sun, 29 Nov 2026 15:52:55 -0800 Qian Xiao <heyheyco@gmail.com> wrote:
> On Sat, 28 Nov 2026 19:12:03 -0800 Andrew Morton wrote:
> > What is the relationship between this and Krystian's identically-named
> > patch?
>
> Thanks for taking a look. Krystian's patch is a4e667346a8d. It only
> changes xas_find(). This is the same fix for xas_find_marked(), and it
> doesn't touch xas_find().
>
> > The kernel was not built.
> >
> > Well that isn't encouraging :(
>
> Fair point. I've since built an x86_64 defconfig vmlinux
> successfully, without errors.
The bug is legit and your patch (after fixing the Sashiko thing) fixes
it.
I'm struggling to figure out the userspace impact of the bug. It seems
to be minor. afaict it's
__folio_mark_dirty() -> set PAGECACHE_TAG_DIRTY
WB_SYNC_ALL or tagged writeback -> transform PAGECACHE_TAG_DIRTY into
PAGECACHE_TAG_TOWRITE
writeback_iter() -> start IO on PAGECACHE_TAG_TOWRITE folios
concurrent split -> uh oh, this makes the marked scan of
mapping->i_pages move its xas.xa_index backwards. This can consume
background writeback's page budget before it reaches later dirty
folios.
I could reproduce the backward jumping in test_xarray and in a kernel
module scanning a real tmpfs page-cache XArray. The module set
PAGECACHE_TAG_DIRTY itself - I couldn't reproduce the
writeback-didn't-write-enough-stuff thing in actual testing.
It turns out that there's more to the world than mm/, but Token Taxing
Terrorist couldn't convincingly find any other xarray users which are
impacted by this. DAX and memfd are "maybe, possibly".
I've temporarily turned your patch into a series of three:
1: add the test
2: add your fix
3: add a (needed) -fix for the Sashiko thing
I like to stage the test before the fix for simplifying the
test-without/test-with testing. Shall scrunch everything
together later.
Sashiko -fix:
--- a/lib/xarray.c~xarray-fix-index-jumping-backwards-in-xas_find_marked-fix
+++ a/lib/xarray.c
@@ -1544,8 +1544,10 @@ void *xas_find_marked(struct xa_state *x
entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset);
if (!entry && !(xa_track_free(xas->xa) && mark == XA_FREE_MARK))
continue;
- if (xa_is_sibling(entry))
+ if (xa_is_sibling(entry)) {
+ advance = true;
continue;
+ }
if (!xa_is_node(entry))
return entry;
if (xas->xa_offset != get_offset(xas->xa_index, xas->xa_node))
_
next prev parent reply other threads:[~2026-12-03 1:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 21:34 [PATCH] " Qian Xiao
2026-11-26 19:08 ` [PATCH v2] " Qian Xiao
2026-11-27 22:21 ` [PATCH v3] " Qian Xiao
2026-11-29 3:12 ` Andrew Morton
2026-11-29 23:52 ` Qian Xiao
2026-12-03 1:06 ` Andrew Morton [this message]
2026-12-03 7:00 ` [syzbot ci] " syzbot ci
2026-12-03 7:13 ` Andrew Morton
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=20261202170644.8b79f3de9e4e9c1df1b85e0f@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=heyheyco@gmail.com \
--cc=krystianmkaniewski@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
/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®