Re: [PATCH] userfaultfd: reset err to be 0 when move_pages_ptes succeeded
From: Foxie Flakey
Date: Mon Aug 17 2026 - 21:30:58 EST
On Mon, 17 Aug 2026, Andrew Morton wrote:
> On Mon, 17 Aug 2026 15:26:05 -0700 Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> > > That behaviour manifested into this at userspace
> > >
> > > Source: [ .. unmapped .. ][ .. mapped ..]
> > > Destination: [ .. mapped .. ][ .. unmapped ..]
> > > ^ ^
> > > \ Kernel moved this far in actuality
> > > What is reported to userspace on struct
> > > uffdio_move's move field
> > >
> > > When the previous behaviour is
> > > Source: [ .. unmapped .. ][ .. mapped ..]
> > > Destination: [ .. mapped .. ][ .. unmapped ..]
> > > ^
> > > Reported to user space via uffdio_move's
> > > move field
>
> Also...
>
> I assume the above illuminates lack of coverage in the uffd selftests.
> Is it hard to add a case to detect this?
>
Yes, I do have self contained reproduer test but there an issue.
The issues I have is:
1. Its only appear when system is under memory pressure and is swapping.
To create enough pressure what work atleast under my test environment, is
to run many reproduer till the test system overloaded with memory (No, its
not just "dd if=/dev/zero of=/tmp/garbage.bin", that doesn't work reliably
from what I have tried).
2. It cannot detect if the problem is fixed, because it ran forever.
What I have thought is somehow rig function move_pages() called that
performs the actual move (which are move_pages_ptes() and I think
move_splits_huge_pmd() too) to fail with -EAGAIN on first call and succeds
after that.
About memory pressure, I figure it has to be related with memory pressure
as VM that is not actively swapping, I cannot reproduce the issue at all no
matter how long I ran it. My hypothesis more less (from my limited
experience in Linux internals + personal osdev), swapping likely causes
move_pages_ptes() to fail temporarily due some pages are evicted to swap
till they moved back to be resident in memory.
For information my test VM configuration is:
Distro: Ubuntu Server 24.04
CPU: 2 cores of AMD Ryzen 3 4300U
RAM: 2 GiB (the lower the best)
Storage: 8 GiB
Kernels tested:
Linux 6.8.0-137-generic -> Unreproduceable (the stock kernel came with
Ubuntu 24.04 which is reason why I used this particular version)
These kernel came from https://kernel.ubuntu.com/mainline/
Linux 6.16.0-061600-generic -> Unreproduceable
Linux 6.17.0-061700-generic -> Unreproduceable
Linux 6.19.0-061900-generic -> Reproducable
Linux 7.1.0-070100-generic -> Reproducable
Linux 7.2.0-070200rc5-generic -> Reproduceable