Re: [PATCH v2 2/2] selftests/mm: add stale walk->action race test
From: Lorenzo Stoakes (ARM)
Date: Mon Aug 17 2026 - 14:05:14 EST
On Tue, Aug 11, 2026 at 08:49:46PM +0200, David Hildenbrand (Arm) wrote:
> On 8/11/26 20:23, Lorenzo Stoakes (ARM) wrote:
> > On Tue, Aug 11, 2026 at 07:11:59PM +0200, David Hildenbrand (Arm) wrote:
> >> On 8/11/26 18:18, Hyunwoo Kim wrote:
> >>> The added pagewalk_race_test maps two PMDs and faults in 2MB of the first
> >>> one. A second thread then faults in the second PMD and drops it again with
> >>> MADV_DONTNEED in a loop, while the main thread reads Rss for the mapping
> >>> from /proc/self/smaps.
> >>>
> >>> Clearing the second PMD while smaps_pte_range() runs leaves walk->action
> >>> erroneously set to ACTION_AGAIN, which causes the PUD walk to be retried,
> >>> so the first PMD is counted twice and Rss comes out twice as large as what
> >>> was faulted in.
> >>>
> >>> mincore() is the caller named in the fix, but the second walk writes past
> >>> the length mincore() copies back, so it cannot be seen from userspace
> >>> there. smaps reports what the callbacks counted, so the duplicate shows up
> >>> in Rss.
> >>>
> >>> A failure can only come from the kernel counting the same page twice, so
> >>> missing the race is harmless. On an unfixed kernel the test fails after a
> >>> few hundred reads at most and takes about half a second.
> >>>
> >>> Assisted-by: Claude:claude-opus-5
> >>> Signed-off-by: Hyunwoo Kim <imv4bel@xxxxxxxxx>
> >>> ---
> >>
> >> I'm sorry, but I don't consider such a specialized reproducer for a problem we
> >> hit once a good fit for a selftest.
> >>
> >> Or am I missing something, that this here is more generic?
> >
> > To be fair I did ask him for this. :)
> >
> > I thought it would be useful to have a regression test because there's certainly
> > no harm in it? The code is very sensitive and catching a similar mistake in
> > future could be useful.
> >
> > If you're sure this isn't valuable then he could just drop it, but it's my fault
> > sorry Hyunwoo for giving you extra work in this case! My bad.
>
> pagewalk_race_test is just rather odd. If this would be part of a bigger test
> that covers more things than just one odd race, it might be better.
>
> But we certainly don't want one new test file for each kernel bug we ever
> trigger, right? :)
Right yeah :) sure we can drop this then. Sorry Hyunwoo!
>
> --
> Cheers,
>
> David
--
Cheers, Lorenzo