Re: [PATCH v3 06/19] hugetlb: Optimize bootmem folios that were not pre-HVOed

From
James Houghton <hidden>
Date
2026-11-24 16:59:27
Also in
linux-mm, lkml
Reply to
Muchun Song, 2026-11-23
On Sun, Nov 22, 2026 at 10:11 PM Muchun Song [off-list ref] wrote:

quoted
On Nov 23, 2026, at 02:44, James Houghton [off-list ref] 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.
quoted
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 <redacted>
---
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.
 */
Applied in v4, thanks!

Also just so you don't miss it, would appreciate your thoughts on my
reply to Sashiko's comments on this patch[1]. Let me know if you would
like me to do something different.

[1] https://lore.kernel.org/linux-mm/20261124165516.1182390-1-jthoughton@google.com/ (local)
Thread (43 messages) 43 messages, 2 authors, last reply 4d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help