[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3029924e-0857-3684-52ea-f37e924ceb4a@oracle.com>
Date: Tue, 31 May 2022 09:56:52 -0700
From: Mike Kravetz <mike.kravetz@...cle.com>
To: Baolin Wang <baolin.wang@...ux.alibaba.com>,
linux-kernel@...r.kernel.org, linux-mm@...ck.org
Cc: Muchun Song <songmuchun@...edance.com>,
Michal Hocko <mhocko@...e.com>, Peter Xu <peterx@...hat.com>,
Naoya Horiguchi <naoya.horiguchi@...ux.dev>,
James Houghton <jthoughton@...gle.com>,
Mina Almasry <almasrymina@...gle.com>,
"Aneesh Kumar K . V" <aneesh.kumar@...ux.vnet.ibm.com>,
Anshuman Khandual <anshuman.khandual@....com>,
Paul Walmsley <paul.walmsley@...ive.com>,
Christian Borntraeger <borntraeger@...ux.ibm.com>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [RFC PATCH 1/3] hugetlb: skip to end of PT page mapping when pte
not present
On 5/30/22 03:10, Baolin Wang wrote:
> On 5/28/2022 6:58 AM, Mike Kravetz wrote:
>
> I tested on my ARM64 machine with implementing arm64 specific hugetlb_mask_last_hp() as below, and it works well.
>
> Just a few nits inline, otherwise looks good to me.
> Tested-by: Baolin Wang <baolin.wang@...ux.alibaba.com>
> Reviewed-by: Baolin Wang <baolin.wang@...ux.alibaba.com>
>
> diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
> index d93ba128a2b0..e04a097ffcc4 100644
> --- a/arch/arm64/mm/hugetlbpage.c
> +++ b/arch/arm64/mm/hugetlbpage.c
> @@ -376,6 +376,28 @@ pte_t *huge_pte_offset(struct mm_struct *mm,
> return NULL;
> }
>
> +unsigned long hugetlb_mask_last_hp(struct hstate *h)
> +{
> + unsigned long hp_size = huge_page_size(h);
> +
> + switch (hp_size) {
> + case P4D_SIZE:
> + return PGDIR_SIZE - P4D_SIZE;
> + case PUD_SIZE:
> + return P4D_SIZE - PUD_SIZE;
> + case CONT_PMD_SIZE:
> + return PUD_SIZE - CONT_PMD_SIZE;
> + case PMD_SIZE:
> + return PUD_SIZE - PMD_SIZE;
> + case CONT_PTE_SIZE:
> + return PMD_SIZE - CONT_PTE_SIZE;
> + default:
> + break;
> + }
> +
> + return ~(0UL);
> +}
>
Thanks! I was hesitant to put something together for those CONT_* sizes.
>> +/*
>> + * Return a mask that can be used to update an address to the last huge
>> + * page in a page table page mapping size. Used to skip non-present
>> + * page table entries when linearly scanning address ranges. Architectures
>> + * with unique huge page to page table relationships can define their own
>> + * version of this routine.
>> + */
>> +unsigned long hugetlb_mask_last_hp(struct hstate *h)
>> +{
>> + unsigned long hp_size = huge_page_size(h);
>> +
>> + if (hp_size == P4D_SIZE)
>> + return PGDIR_SIZE - P4D_SIZE;
>> + else if (hp_size == PUD_SIZE)
>> + return P4D_SIZE - PUD_SIZE;
>> + else if (hp_size == PMD_SIZE)
>> + return PUD_SIZE - PMD_SIZE;
>
> Changing to use 'switch' looks more readable?
Agree. Or, I might just go with Peter's simplification.
>
>> +
>> + return ~(0);
>
> Better to return '~(0UL)' to keep function type consistent.
Yes, thanks!
--
Mike Kravetz
Powered by blists - more mailing lists