summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Lim <foxieflakey@gmail.com>2026-08-19 10:08:24 +0700
committerAndrew Morton <akpm@linux-foundation.org>2026-09-01 20:26:21 -0700
commitf025ca73decda1f895a4b80b961d3bc88825298a (patch)
treed90bd8a5bfdf0036546c8b50079e976e5e65f684
parent2fd4e7693674b17807a6d082feb01a3fbf86f5f8 (diff)
downloadlinux-f025ca73decda1f895a4b80b961d3bc88825298a.tar.gz
linux-f025ca73decda1f895a4b80b961d3bc88825298a.zip
userfaultfd: reset err to be 0 when move_pages_ptes succeeded
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. Link: https://lore.kernel.org/e1e0b5f8-c3c6-0537-670b-4397f822f980@gmail.com 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@gmail.com> Reviewed-by: Suren Baghdasaryan <surenb@google.com> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Cc: Peter Xu <peterx@redhat.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r--mm/userfaultfd.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
index 23fb68fce000..74f04c323c50 100644
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -2171,8 +2171,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;
}