Re: [PATCH v3 06/19] hugetlb: Optimize bootmem folios that were not pre-HVOed
From: Muchun Song
Date: Sun Nov 22 2026 - 22:11:26 EST
> On Nov 23, 2026, at 02:44, James Houghton <jthoughton@xxxxxxxxxx> wrote:
>
> Boot-time gigantic folios are expected to be pre-HVOed through the
> section-based vmemmap optimization, so the bulk optimization pass for
> bootmem folios was dropped.
>
> However, arch_support_vmemmap_remap() may not yet
> return true when bootmem folios are allocated (e.g. on arm64, where
> support depends on a system-wide CPU capability), while it does return
> true by the time the bootmem folios are gathered. Such architectures
> disable the section-based vmemmap optimization in their vmemmap
> population path (see section_vmemmap_optimization_disable()), so the
> folios are not pre-HVOed and would never be optimized.
Yeah, when I removed support for this part of the code, I figured you
might add a new patch in the future to add support back. It is fine.
>
> Optimize such folios when gathering bootmem folios. Their tail struct
> pages have all been initialized by memmap_init_compound_page(),
> as they were not pre-HVOed. Pre-HVOed folios are skipped by
> vmemmap_should_optimize_folio().
>
> Signed-off-by: James Houghton <jthoughton@xxxxxxxxxx>
> ---
> mm/hugetlb.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 72839e98f998..8756c0206922 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -3325,6 +3325,17 @@ static void __init prep_and_add_bootmem_folios(struct hstate *h,
> unsigned long flags;
> struct folio *folio, *tmp_f;
>
> + /*
> + * Bootmem folios are normally pre-HVOed through the section-based
> + * vmemmap optimization. However, an architecture that can only
> + * determine whether it supports HVO after bootmem allocation disables
> + * the section-based optimization (see
> + * section_vmemmap_optimization_disable()), in which case the folios
> + * were not pre-HVOed and must be optimized now. Pre-HVOed folios are
> + * skipped.
> + */
I'd like to condense these comments to something like:
/*
* Some architectures do not support section-based vmemmap optimization,
* so their bootmem folios should be optimized here with folio-based
* optimization.
*/
Thanks,
Muchun
> + hugetlb_vmemmap_optimize_folios(h, folio_list);
> +
> list_for_each_entry_safe(folio, tmp_f, folio_list, lru) {
> /* Subdivide locks to achieve better parallel performance */
> spin_lock_irqsave(&hugetlb_lock, flags);
> --
> 2.56.1.809.ga0b61035b5-goog
>