linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/3] userfaultfd: use vma_pagesize for all huge page size calculation
@ 2019-09-27  7:00 Wei Yang
  2019-09-27  7:00 ` [PATCH v2 2/3] userfaultfd: remove unnecessary warn_on in __mcopy_atomic_hugetlb Wei Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Wei Yang @ 2019-09-27  7:00 UTC (permalink / raw)
  To: akpm, aarcange, hughd, mike.kravetz; +Cc: linux-mm, Wei Yang

In function __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.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 mm/userfaultfd.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
index a998c1b4d8a1..01ad48621bb7 100644
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -262,7 +262,7 @@ static __always_inline ssize_t __mcopy_atomic_hugetlb(struct mm_struct *dst_mm,
 		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 @@ static __always_inline ssize_t __mcopy_atomic_hugetlb(struct mm_struct *dst_mm,
 		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 @@ static __always_inline ssize_t __mcopy_atomic_hugetlb(struct mm_struct *dst_mm,
 
 			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;
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-10-08  0:57 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-27  7:00 [PATCH v2 1/3] userfaultfd: use vma_pagesize for all huge page size calculation Wei Yang
2019-09-27  7:00 ` [PATCH v2 2/3] userfaultfd: remove unnecessary warn_on in __mcopy_atomic_hugetlb Wei Yang
2019-09-27  7:00 ` [PATCH v2 3/3] userfaultfd: wrap the common dst_vma check into an inlined function Wei Yang
2019-09-27 22:10 ` [PATCH v2 1/3] userfaultfd: use vma_pagesize for all huge page size calculation Andrew Morton
2019-09-27 22:21   ` Mike Kravetz
2019-10-05  0:34     ` Wei Yang
2019-09-29  0:45   ` Wei Yang
2019-10-07 22:55     ` Mike Kravetz
2019-10-08  0:57       ` Wei Yang
2019-10-05  0:33   ` [PATCH] hugetlb: remove unused hstate in hugetlb_fault_mutex_hash() Wei Yang
2019-10-05  5:42     ` kbuild test robot
2019-10-05  5:43     ` kbuild test robot
2019-10-06  2:25     ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).