Re: [PATCH v6 1/6] arm64/hugetlb: Extend batching of multiple CONT_PTE in a single PTE setup
From: Wen Jiang
Date: Tue Jul 14 2026 - 04:38:31 EST
On Tue, 14 Jul 2026 at 14:54, Anshuman Khandual
<anshuman.khandual@xxxxxxx> wrote:
>
> On 09/07/26 1:08 PM, Wen Jiang wrote:
> > From: "Barry Song (Xiaomi)" <baohua@xxxxxxxxxx>
> >
> > For sizes aligned to CONT_PTE_SIZE and smaller than PMD_SIZE,
> > we can handle CONT_PTE_SIZE groups together.
> >
> > Signed-off-by: Barry Song (Xiaomi) <baohua@xxxxxxxxxx>
> > Signed-off-by: Wen Jiang <jiangwen6@xxxxxxxxxx>
> > Tested-by: Xueyuan Chen <xueyuan.chen21@xxxxxxxxx>
> > Tested-by: Leo Yan <leo.yan@xxxxxxx>
> > Reviewed-by: Dev Jain <dev.jain@xxxxxxx>
> > ---
> > arch/arm64/mm/hugetlbpage.c | 10 ++++++++++
> > 1 file changed, 10 insertions(+)
> >
> > diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
> > index a42c05cf56408..0da746f729388 100644
> > --- a/arch/arm64/mm/hugetlbpage.c
> > +++ b/arch/arm64/mm/hugetlbpage.c
> > @@ -110,6 +110,12 @@ static inline int num_contig_ptes(unsigned long size, size_t *pgsize)
> > contig_ptes = CONT_PTES;
> > break;
> > default:
> > + if (size > 0 && size < PMD_SIZE &&
>
> Is there a possibility for size <= 0 ? If not then
> the above conditional check might be redundant.
Hi Anshuman,
The "size > 0" check is to guard against size == 0.
> > + IS_ALIGNED(size, CONT_PTE_SIZE)) {
> > + *pgsize = PAGE_SIZE;
> > + contig_ptes = size >> PAGE_SHIFT;
> > + break;
> > + }
> > WARN_ON(!__hugetlb_valid_size(size));
>
> Would not these CONT_PTE_SIZE aligned sizes upto PMD_SIZE
> trigger warning here because __hugetlb_valid_size() still
> does not enumerate them ?
The intermediate CONT_PTE_SIZE-aligned sizes will not hit the WARN_ON(),
as they are handled by the new branch and break before the
__hugetlb_valid_size() check. They are accepted here for vmalloc's partial
contiguous-PTE mappings.
Thanks,
Wen
> > }
> >
> > @@ -359,6 +365,10 @@ pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags)
> > case CONT_PTE_SIZE:
> > return pte_mkcont(entry);
> > default:
> > + if (pagesize > 0 && pagesize < PMD_SIZE &&
> > + IS_ALIGNED(pagesize, CONT_PTE_SIZE))
> > + return pte_mkcont(entry);
> > +
> > break;
> > }
> > pr_warn("%s: unrecognized huge page size 0x%lx\n",
>