]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/userfaultfd: Change mfill_atomic_hugetlb() locking to align with mfill_atomic...
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 23 Oct 2025 02:41:00 +0000 (22:41 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 30 Oct 2025 16:13:04 +0000 (12:13 -0400)
hugetlb locks the context before validating the hugetlb (which is
already stable).  Reversing the order better aligns with the other
memory types and has no need to be different.

This is important to follow the logic of later patches of combining the
memory types into the same code.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
mm/userfaultfd.c

index 1b7828a0acfa771a781bf3e17ec3bd57ea33b50f..2a81b4982f7404a645938a17193d6940b992fa92 100644 (file)
@@ -541,14 +541,6 @@ retry:
                        goto out;
                }
 
-               err = -ENOENT;
-               if (!is_vm_hugetlb_page(dst_vma))
-                       goto out_unlock_vma;
-
-               err = -EINVAL;
-               if (vma_hpagesize != vma_kernel_pagesize(dst_vma))
-                       goto out_unlock_vma;
-
                /*
                 * If memory mappings are changing because of non-cooperative
                 * operation (e.g. mremap) running in parallel, bail out and
@@ -558,6 +550,14 @@ retry:
                err = -EAGAIN;
                if (atomic_read(&ctx->mmap_changing))
                        goto out_unlock;
+
+               err = -ENOENT;
+               if (!is_vm_hugetlb_page(dst_vma))
+                       goto out_unlock;
+
+               err = -EINVAL;
+               if (vma_hpagesize != vma_kernel_pagesize(dst_vma))
+                       goto out_unlock;
        }
 
        while (src_addr < src_start + len) {
@@ -630,7 +630,6 @@ retry:
 
 out_unlock:
        up_read(&ctx->map_changing_lock);
-out_unlock_vma:
        uffd_mfill_unlock(dst_vma);
 out:
        if (folio)