From: Mike Kravetz <mike.kravetz@oracle.com>
To: Li Xinhai <lixinhai.lxh@gmail.com>, linux-mm@kvack.org
Cc: akpm@linux-foundation.org, Peter Xu <peterx@redhat.com>
Subject: Re: [PATCH] mm/hugetlb.c: fix unnecessary address expansion of pmd sharing
Date: Mon, 4 Jan 2021 10:59:05 -0800 [thread overview]
Message-ID: <6aaf1556-33e1-c9cd-5f41-11cd96c014f4@oracle.com> (raw)
In-Reply-To: <1617a471-b837-a868-67a0-0b0f17cb3748@gmail.com>
On 1/3/21 11:10 PM, Li Xinhai wrote:
>
>
> On 1/4/21 11:55 AM, Mike Kravetz wrote:
>> I believe the only case where your patch produced incorrect results is
>> when the range was within a vma that was smaller than PUD_SIZE. Do you
>> agree?
>>
> Not exactly. We need to consider for vma which span at least one
> PUD_SIZE after align its vm_start and vm_end.
>
I know that I provided an incorrect example again. Sorry (again)!
Can you provide an example where adding the simple check for vma size less
than PUD_SIZE to your original patch will not work. The logic in your V2
patch is correct. However, I am having a hard time finding a problem with
this simpler approach.
--
Mike Kravetz
>> If that is the case, then how about just adding the following to your patch?
>> I think this is simpler and faster than the 'range_in_vma' checking I proposed.
>>
>> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
>> index 49990c0a02a3..716d1e58a7ae 100644
>> --- a/mm/hugetlb.c
>> +++ b/mm/hugetlb.c
>> @@ -5261,7 +5261,9 @@ void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma,
>> {
>> unsigned long a_start, a_end;
>> - if (!(vma->vm_flags & VM_MAYSHARE))
>> + /* Quick check for vma capable of pmd sharing */
>> + if (!(vma->vm_flags & VM_MAYSHARE) ||
>> + (vma->vm_start - vma->vm_end) < PUD_SIZE)
>> return;
>> /* Extend the range to be PUD aligned for a worst case scenario */
>
> Your suggestion is good, we are able to simplify the code a bit, with
> less comparison, and maybe easier to follow. I will send a new patch to
> review.
next prev parent reply other threads:[~2021-01-04 18:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-29 4:21 Li Xinhai
2020-12-29 19:21 ` Andrew Morton
2020-12-29 21:20 ` Mike Kravetz
2020-12-31 17:56 ` Mike Kravetz
2021-01-02 11:56 ` Li Xinhai
2021-01-04 3:55 ` Mike Kravetz
2021-01-04 7:10 ` Li Xinhai
2021-01-04 18:59 ` Mike Kravetz [this message]
2021-01-05 2:10 ` Li Xinhai
2021-01-05 2:38 ` Li Xinhai
2021-01-05 18:20 ` Mike Kravetz
2020-12-30 18:42 ` Peter Xu
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=6aaf1556-33e1-c9cd-5f41-11cd96c014f4@oracle.com \
--to=mike.kravetz@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=lixinhai.lxh@gmail.com \
--cc=peterx@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox