lkml.org 
[lkml]   [2022]   [May]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RFC PATCH 1/3] hugetlb: skip to end of PT page mapping when pte not present
From
On 5/30/22 19:04, Muchun Song wrote:
> On Mon, May 30, 2022 at 03:56:43PM -0400, Peter Xu wrote:
>> Hi, Mike,
>>
>> On Fri, May 27, 2022 at 03:58:47PM -0700, Mike Kravetz wrote:
>>> +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;
>>> +
>>> + return ~(0);
>>> +}
>>
>> How about:
>>
>> unsigned long hugetlb_mask_last_hp(struct hstate *h)
>> {
>> unsigned long hp_size = huge_page_size(h);
>>
>> return hp_size * (PTRS_PER_PTE - 1);
>> }
>>
>
> +1
>


I like this as well, but I wonder if we should put something like the
following in just to be safe.

BUILD_BUG_ON(PTRS_PER_PTE != PTRS_PER_PMD);
BUILD_BUG_ON(PTRS_PER_PTE != PTRS_PER_PUD);
BUILD_BUG_ON(PTRS_PER_PTE != PTRS_PER_P4D);

--
Mike Kravetz

\
 
 \ /
  Last update: 2022-05-31 19:06    [W:0.536 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site