From: Miaohe Lin <linmiaohe@huawei.com>
To: Mike Kravetz <mike.kravetz@oracle.com>, <akpm@linux-foundation.org>
Cc: <n-horiguchi@ah.jp.nec.com>, <hillf.zj@alibaba-inc.com>,
<linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>
Subject: Re: [PATCH 2/4] mm/hugeltb: simplify the return code of __vma_reservation_common()
Date: Wed, 7 Apr 2021 10:05:12 +0800 [thread overview]
Message-ID: <40114ff5-ba3d-ca66-3338-25db80a015da@huawei.com> (raw)
In-Reply-To: <e958d731-67d4-a56b-aa1d-a8054cf232f2@oracle.com>
Hi:
On 2021/4/7 8:53, Mike Kravetz wrote:
> On 4/2/21 2:32 AM, Miaohe Lin wrote:
>> It's guaranteed that the vma is associated with a resv_map, i.e. either
>> VM_MAYSHARE or HPAGE_RESV_OWNER, when the code reaches here or we would
>> have returned via !resv check above. So ret must be less than 0 in the
>> 'else' case. Simplify the return code to make this clear.
>
> I believe we still neeed that ternary operator in the return statement.
> Why?
>
> There are two basic types of mappings to be concerned with:
> shared and private.
> For private mappings, a task can 'own' the mapping as indicated by
> HPAGE_RESV_OWNER. Or, it may not own the mapping. The most common way
> to create a non-owner private mapping is to have a task with a private
> mapping fork. The parent process will have HPAGE_RESV_OWNER set, the
> child process will not. The idea is that since the child has a COW copy
> of the mapping it should not consume reservations made by the parent.
The child process will not have HPAGE_RESV_OWNER set because at fork time, we do:
/*
* Clear hugetlb-related page reserves for children. This only
* affects MAP_PRIVATE mappings. Faults generated by the child
* are not guaranteed to succeed, even if read-only
*/
if (is_vm_hugetlb_page(tmp))
reset_vma_resv_huge_pages(tmp);
i.e. we have vma->vm_private_data = (void *)0; for child process and vma_resv_map() will
return NULL in this case.
Or am I missed something?
> Only the parent (HPAGE_RESV_OWNER) is allowed to consume the
> reservations.
> Hope that makens sense?
>
>>
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>> ---
>> mm/hugetlb.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
>> index a03a50b7c410..b7864abded3d 100644
>> --- a/mm/hugetlb.c
>> +++ b/mm/hugetlb.c
>> @@ -2183,7 +2183,7 @@ static long __vma_reservation_common(struct hstate *h,
>> return 1;
>> }
>> else
>
> This else also handles the case !HPAGE_RESV_OWNER. In this case, we
IMO, for the case !HPAGE_RESV_OWNER, we won't reach here. What do you think?
> never want to indicate reservations are available. The ternary makes
> sure a positive value is never returned.
>
Many thanks for review and reply! :)
next prev parent reply other threads:[~2021-04-07 2:05 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-02 9:32 [PATCH 0/4] Cleanup and fixup for hugetlb Miaohe Lin
2021-04-02 9:32 ` [PATCH 1/4] mm/hugeltb: remove redundant VM_BUG_ON() in region_add() Miaohe Lin
2021-04-07 0:16 ` Mike Kravetz
2021-04-02 9:32 ` [PATCH 2/4] mm/hugeltb: simplify the return code of __vma_reservation_common() Miaohe Lin
2021-04-07 0:53 ` Mike Kravetz
2021-04-07 2:05 ` Miaohe Lin [this message]
2021-04-07 2:37 ` Mike Kravetz
2021-04-07 3:09 ` Miaohe Lin
2021-04-07 21:23 ` Mike Kravetz
2021-04-08 2:44 ` Miaohe Lin
2021-04-08 22:40 ` Mike Kravetz
2021-04-09 2:52 ` Miaohe Lin
2021-04-02 9:32 ` [PATCH 3/4] mm/hugeltb: fix potential wrong gbl_reserve value for hugetlb_acct_memory() Miaohe Lin
2021-04-07 2:49 ` Mike Kravetz
2021-04-07 7:24 ` Miaohe Lin
2021-04-07 20:53 ` Mike Kravetz
2021-04-08 3:24 ` Miaohe Lin
2021-04-08 3:26 ` Miaohe Lin
2021-04-08 22:53 ` Mike Kravetz
2021-04-09 3:01 ` Miaohe Lin
2021-04-09 4:37 ` Mike Kravetz
2021-04-09 6:36 ` Miaohe Lin
2021-04-02 9:32 ` [PATCH 4/4] mm/hugeltb: handle the error case in hugetlb_fix_reserve_counts() Miaohe Lin
2021-04-08 23:25 ` Mike Kravetz
2021-04-09 3:17 ` Miaohe Lin
2021-04-09 5:04 ` Andrew Morton
2021-04-09 7:07 ` Miaohe Lin
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=40114ff5-ba3d-ca66-3338-25db80a015da@huawei.com \
--to=linmiaohe@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=hillf.zj@alibaba-inc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=n-horiguchi@ah.jp.nec.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