From: Wei Yang <richardw.yang@linux.intel.com>
To: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Wei Yang <richardw.yang@linux.intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
aarcange@redhat.com, hughd@google.com, linux-mm@kvack.org
Subject: Re: [PATCH v2 1/3] userfaultfd: use vma_pagesize for all huge page size calculation
Date: Tue, 8 Oct 2019 08:57:25 +0800 [thread overview]
Message-ID: <20191008005725.GA13077@richard> (raw)
In-Reply-To: <f405e537-1cc2-6d40-4d2b-f30e19d68ac9@oracle.com>
On Mon, Oct 07, 2019 at 03:55:21PM -0700, Mike Kravetz wrote:
>On 9/28/19 5:45 PM, Wei Yang wrote:
>> On Fri, Sep 27, 2019 at 03:10:33PM -0700, Andrew Morton wrote:
>>> On Fri, 27 Sep 2019 15:00:30 +0800 Wei Yang <richardw.yang@linux.intel.com> 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..
>>
>> Oops, haven't imagine h is not used in the function.
>>
>>
>> Any historical reason to pass h in hugetlb_fault_mutex_hash()? Neither these
>> two definition use it.
>
>See 1b426bac66e6 ("hugetlb: use same fault hash key for shared and private
>mappings"). Prior to that change, the hash key for private mappings was
>created by:
>
> key[0] = (unsigned long) mm;
> key[1] = address >> huge_page_shift(h);
>
>When removing that code, I should have removed 'h'.
Thanks for this information.
>--
>Mike Kravetz
--
Wei Yang
Help you, Help me
next prev parent reply other threads:[~2019-10-08 0:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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:42 ` kbuild test robot
2019-10-05 5:43 ` kbuild test robot
2019-10-05 5:43 ` kbuild test robot
2019-10-06 2:25 ` kbuild test robot
2019-10-06 2:25 ` kbuild test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191008005725.GA13077@richard \
--to=richardw.yang@linux.intel.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.