userfaultfd: mfill_atomic(): remove retry logic

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().

[[email protected]: remove safety measure of not returning ENOENT from _copy]
  Link: https://lore.kernel.org/[email protected]
Link: https://lore.kernel.org/[email protected]
Signed-off-by: Mike Rapoport (Microsoft) <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Cc: Andrei Vagin <[email protected]>
Cc: Axel Rasmussen <[email protected]>
Cc: Baolin Wang <[email protected]>
Cc: David Hildenbrand (Arm) <[email protected]>
Cc: Harry Yoo <[email protected]>
Cc: Harry Yoo (Oracle) <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: James Houghton <[email protected]>
Cc: Liam Howlett <[email protected]>
Cc: Lorenzo Stoakes (Oracle) <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Muchun Song <[email protected]>
Cc: Nikita Kalyazin <[email protected]>
Cc: Oscar Salvador <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: Peter Xu <[email protected]>
Cc: Sean Christopherson <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: Suren Baghdasaryan <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: David Carlier <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
This commit is contained in:
Mike Rapoport (Microsoft) authored and Andrew Morton committed 2026-04-18 00:10:54 -07:00
1 parent f74991b4e3
commit 6ab703034f
1 file changed
-27
-27
View File
@@ -29,7 +29,6 @@ struct mfill_state {
struct vm_area_struct *vma;
unsigned long src_addr;
unsigned long dst_addr;
struct folio *folio;
pmd_t *pmd;
};
@@ -531,9 +530,6 @@ err_filemap_remove:
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;
}
@@ -899,7 +895,6 @@ static __always_inline ssize_t mfill_atomic(struct userfaultfd_ctx *ctx,
VM_WARN_ON_ONCE(src_start + len <= src_start);
VM_WARN_ON_ONCE(dst_start + len <= dst_start);
retry:
err = mfill_get_vma(&state);
if (err)
goto out;
@@ -926,26 +921,6 @@ retry:
err = mfill_atomic_pte(&state);
cond_resched();
if (unlikely(err == -ENOENT)) {
void *kaddr;
mfill_put_vma(&state);
VM_WARN_ON_ONCE(!state.folio);
kaddr = kmap_local_folio(state.folio, 0);
err = copy_from_user(kaddr,
(const void __user *)state.src_addr,
PAGE_SIZE);
kunmap_local(kaddr);
if (unlikely(err)) {
err = -EFAULT;
goto out;
}
flush_dcache_folio(state.folio);
goto retry;
} else
VM_WARN_ON_ONCE(state.folio);
if (!err) {
state.dst_addr += PAGE_SIZE;
state.src_addr += PAGE_SIZE;
@@ -960,8 +935,6 @@ retry:
mfill_put_vma(&state);
out:
if (state.folio)
folio_put(state.folio);
VM_WARN_ON_ONCE(copied < 0);
VM_WARN_ON_ONCE(err > 0);
VM_WARN_ON_ONCE(!copied && !err);