Re: [PATCH v4 11/15] userfaultfd: mfill_atomic(): remove retry logic

From: Mike Rapoport

Date: Thu Apr 02 2026 - 09:58:16 EST


On Thu, Apr 02, 2026 at 07:11:52AM +0300, Mike Rapoport wrote:
> From: "Mike Rapoport (Microsoft)" <rppt@xxxxxxxxxx>
>
> Since __mfill_atomic_pte() handles the retry for both anonymous and shmem,
> there is no need to retry copying the date from the userspace in the loop
> in mfill_atomic().
>
> Drop the retry logic from mfill_atomic().
>
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
> ---
> mm/userfaultfd.c | 24 ------------------------
> 1 file changed, 24 deletions(-)

After discussion with David Carlier about potential replacement of VMA in
mfill_copy_folio_retry(), I looked again in the code and realized that
after all the rebases I didn't remove the bit that temporarily prevented
returning ENOENT from __mfill_atomic_pte().

Andrew, can you please fold this into "userfaultfd: mfill_atomic(): remove
retry logic"?

For a change it applies cleanly :)

commit 5173c8f4fd32f314907b3804217ef57d4e3a2220
Author: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
Date: Thu Apr 2 16:38:39 2026 +0300

userfaultfd: remove safety mesaure of not returning ENOENT from _copy

Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>

diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
index 935a3f6ebeed..dfd7094b1c40 100644
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -530,9 +530,6 @@ static int __mfill_atomic_pte(struct mfill_state *state,
ops->filemap_remove(folio, state->vma);
err_folio_put:
folio_put(folio);
- /* Don't return -ENOENT so that our caller won't retry */
- if (ret == -ENOENT)
- ret = -EFAULT;
return ret;
}



--
Sincerely yours,
Mike.