Re: [PATCH v2 1/3] userfaultfd: use vma_pagesize for all huge page size calculation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 27 Sep 2019 15:00:30 +0800 Wei Yang <richardw.yang@xxxxxxxxxxxxxxx> wrote:

> 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.
> 
> --- 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;

Looks right.

We could go ahead and remove local variable `h', given that
hugetlb_fault_mutex_hash() doesn't actually use its first arg..




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux