Re: [PATCH 1/4] hugetlb: skip to end of PT page mapping when pte not present
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
- Subject: Re: [PATCH 1/4] hugetlb: skip to end of PT page mapping when pte not present
- From: Peter Xu <peterx@xxxxxxxxxx>
- Date: Fri, 17 Jun 2022 10:15:34 -0400
- Cc: linux-kernel@xxxxxxxxxxxxxxx, linux-mm@xxxxxxxxx, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, linux-s390@xxxxxxxxxxxxxxx, linux-sh@xxxxxxxxxxxxxxx, sparclinux@xxxxxxxxxxxxxxx, linux-ia64@xxxxxxxxxxxxxxx, linux-mips@xxxxxxxxxxxxxxx, linux-parisc@xxxxxxxxxxxxxxx, linuxppc-dev@xxxxxxxxxxxxxxxx, Muchun Song <songmuchun@xxxxxxxxxxxxx>, Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>, Michal Hocko <mhocko@xxxxxxxx>, Naoya Horiguchi <naoya.horiguchi@xxxxxxxxx>, James Houghton <jthoughton@xxxxxxxxxx>, Mina Almasry <almasrymina@xxxxxxxxxx>, "Aneesh Kumar K . V" <aneesh.kumar@xxxxxxxxxxxxxxxxxx>, Anshuman Khandual <anshuman.khandual@xxxxxxx>, Paul Walmsley <paul.walmsley@xxxxxxxxxx>, Christian Borntraeger <borntraeger@xxxxxxxxxxxxx>, catalin.marinas@xxxxxxx, will@xxxxxxxxxx, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
- In-reply-to: <20220616210518.125287-2-mike.kravetz@oracle.com>
- References: <20220616210518.125287-1-mike.kravetz@oracle.com> <20220616210518.125287-2-mike.kravetz@oracle.com>
Hi, Mike,
On Thu, Jun 16, 2022 at 02:05:15PM -0700, Mike Kravetz wrote:
> @@ -6877,6 +6896,39 @@ pte_t *huge_pte_offset(struct mm_struct *mm,
> return (pte_t *)pmd;
> }
>
> +/*
> + * 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_page(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 PMD_SIZE:
> + return PUD_SIZE - PMD_SIZE;
> + default:
Should we add a WARN_ON_ONCE() if it should never trigger?
> + break; /* Should never happen */
> + }
> +
> + return ~(0UL);
> +}
> +
> +#else
> +
> +/* See description above. Architectures can provide their own version. */
> +__weak unsigned long hugetlb_mask_last_page(struct hstate *h)
> +{
> + return ~(0UL);
I'm wondering whether it's better to return 0 rather than ~0 by default.
Could an arch with !CONFIG_ARCH_WANT_GENERAL_HUGETLB wrongly skip some
valid address ranges with ~0, or perhaps I misread?
Thanks,
--
Peter Xu
[Index of Archives]
[Linux Kernel]
[Sparc Linux]
[DCCP]
[Linux ARM]
[Yosemite News]
[Linux SCSI]
[Linux x86_64]
[Linux for Ham Radio]