The patch titled Subject: mm/hugetlb: use hugetlb_pte_stable in migration race check has been added to the -mm mm-unstable branch. Its filename is mm-hugetlb-use-hugetlb_pte_stable-in-migration-race-check.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-hugetlb-use-hugetlb_pte_stable-in-migration-race-check.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Peter Xu <peterx@xxxxxxxxxx> Subject: mm/hugetlb: use hugetlb_pte_stable in migration race check Date: Tue, 4 Oct 2022 15:33:59 -0400 After hugetlb_pte_stable() introduced, we can also rewrite the migration race condition against page allocation to use the new helper too. Link: https://lkml.kernel.org/r/20221004193400.110155-3-peterx@xxxxxxxxxx Signed-off-by: Peter Xu <peterx@xxxxxxxxxx> Reviewed-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx> Reviewed-by: David Hildenbrand <david@xxxxxxxxxx> Cc: Andrea Arcangeli <aarcange@xxxxxxxxxx> Cc: Axel Rasmussen <axelrasmussen@xxxxxxxxxx> Cc: Mike Rapoport <rppt@xxxxxxxxxxxxxxxxxx> Cc: Nadav Amit <nadav.amit@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/hugetlb.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/mm/hugetlb.c~mm-hugetlb-use-hugetlb_pte_stable-in-migration-race-check +++ a/mm/hugetlb.c @@ -5623,11 +5623,10 @@ static vm_fault_t hugetlb_no_page(struct * here. Before returning error, get ptl and make * sure there really is no pte entry. */ - ptl = huge_pte_lock(h, mm, ptep); - ret = 0; - if (huge_pte_none(huge_ptep_get(ptep))) + if (hugetlb_pte_stable(h, mm, ptep, old_pte)) ret = vmf_error(PTR_ERR(page)); - spin_unlock(ptl); + else + ret = 0; goto out; } clear_huge_page(page, address, pages_per_huge_page(h)); _ Patches currently in -mm which might be from peterx@xxxxxxxxxx are mm-uffd-fix-warning-without-pte_marker_uffd_wp-compiled-in.patch mm-hugetlb-fix-race-condition-of-uffd-missing-minor-handling.patch mm-hugetlb-use-hugetlb_pte_stable-in-migration-race-check.patch mm-selftest-uffd-explain-the-write-missing-fault-check.patch