The patch titled Subject: userfaultfd: use vma_pagesize for all huge page size calculation has been added to the -mm tree. Its filename is userfaultfd-use-vma_pagesize-for-all-huge-page-size-calculation.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/userfaultfd-use-vma_pagesize-for-all-huge-page-size-calculation.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/userfaultfd-use-vma_pagesize-for-all-huge-page-size-calculation.patch 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 and is updated there every 3-4 working days ------------------------------------------------------ From: Wei Yang <richardw.yang@xxxxxxxxxxxxxxx> Subject: userfaultfd: use vma_pagesize for all huge page size calculation In __mcopy_atomic_hugetlb() we use two variables to deal with huge page size: vma_hpagesize and huge_page_size. Since they are the same, it is not necessary to use two different mechanism. This patch makes it consistent by all using vma_hpagesize. Link: http://lkml.kernel.org/r/20190927070032.2129-1-richardw.yang@xxxxxxxxxxxxxxx Signed-off-by: Wei Yang <richardw.yang@xxxxxxxxxxxxxxx> Cc: Andrea Arcangeli <aarcange@xxxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Cc: Mike Kravetz <mike.kravetz@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/userfaultfd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/mm/userfaultfd.c~userfaultfd-use-vma_pagesize-for-all-huge-page-size-calculation +++ a/mm/userfaultfd.c @@ -262,7 +262,7 @@ retry: pte_t dst_pteval; BUG_ON(dst_addr >= dst_start + len); - VM_BUG_ON(dst_addr & ~huge_page_mask(h)); + VM_BUG_ON(dst_addr & (vma_hpagesize - 1)); /* * Serialize via hugetlb_fault_mutex @@ -273,7 +273,7 @@ retry: mutex_lock(&hugetlb_fault_mutex_table[hash]); err = -ENOMEM; - dst_pte = huge_pte_alloc(dst_mm, dst_addr, huge_page_size(h)); + dst_pte = huge_pte_alloc(dst_mm, dst_addr, vma_hpagesize); if (!dst_pte) { mutex_unlock(&hugetlb_fault_mutex_table[hash]); goto out_unlock; @@ -300,7 +300,8 @@ retry: err = copy_huge_page_from_user(page, (const void __user *)src_addr, - pages_per_huge_page(h), true); + vma_hpagesize / PAGE_SIZE, + true); if (unlikely(err)) { err = -EFAULT; goto out; _ Patches currently in -mm which might be from richardw.yang@xxxxxxxxxxxxxxx are userfaultfd-use-vma_pagesize-for-all-huge-page-size-calculation.patch userfaultfd-remove-unnecessary-warn_on-in-__mcopy_atomic_hugetlb.patch userfaultfd-wrap-the-common-dst_vma-check-into-an-inlined-function.patch