Re: [PATCH v3] userfaultfd: reset err to be 0 when move_pages_ptes succeeded
From: Andrew Morton
Date: Tue Aug 18 2026 - 23:29:37 EST
On Wed, 19 Aug 2026 10:08:24 +0700 (WIB) Foxie Flakey <foxieflakey@xxxxxxxxx> wrote:
>
> During move_pages() operation, when move_pages_ptes() returns EAGAIN,
> the error code is not cleared even after we processed it. This leads
> to a successful retry but then the same pages are retried again due to
> the stale error code. This time move fails because pages are already
> moved, loop is terminated and move_pages() reports a failure.
> Clear the error code once we processes EAGAIN.
>
> Fixes: 50944692052b ("userfaultfd: opportunistic TLB-flush batching for present pages in MOVE")
> Assisted-by: ChatGPT:GPT-5.6-Luna
> Signed-off-by: Bryan Lim <foxieflakey@xxxxxxxxx>
Thanks, Bryan.
More paperwork: the signoff is supposed to match the Author:. The way
to do this is to add an explicit From: line at start-of-changelog. If
this is not present, we fall back to the email envelope's From:.
> --- a/mm/userfaultfd.c
> +++ b/mm/userfaultfd.c
> @@ -2085,8 +2085,10 @@ static ssize_t move_pages(struct userfaultfd_ctx *ctx, unsigned long dst_start,
> }
>
> if (err) {
> - if (err == -EAGAIN)
> + if (err == -EAGAIN) {
> + err = 0;
> continue;
> + }
> break;
> }
I'll queue it, with an adjusted From:, as above.
Could reviewers please advise on whether we should backport this into
-stable kernels?