[PATCH 14/17] mm/hugetlb: remove HUGE_BOOTMEM_HVO

From: Muchun Song

Date: Thu Jul 02 2026 - 06:02:21 EST


The HUGE_BOOTMEM_HVO flag tracked whether a bootmem huge page had
already gone through the old early vmemmap optimization path.

Now that HugeTLB uses section-based vmemmap optimization, that state is
already reflected in the section order.

Remove HUGE_BOOTMEM_HVO and its helper, and use the section state
directly when deciding whether to mark a folio as vmemmap-optimized.

Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
---
include/linux/hugetlb.h | 5 ++---
mm/hugetlb.c | 12 +-----------
mm/hugetlb_vmemmap.c | 2 --
3 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index b7c86dc7aacc..a051c5d6549e 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -674,9 +674,8 @@ struct hstate {
char name[HSTATE_NAME_LEN];
};

-#define HUGE_BOOTMEM_HVO 0x0001
-#define HUGE_BOOTMEM_ZONES_VALID 0x0002
-#define HUGE_BOOTMEM_CMA 0x0004
+#define HUGE_BOOTMEM_ZONES_VALID BIT(0)
+#define HUGE_BOOTMEM_CMA BIT(1)

int isolate_or_dissolve_huge_folio(struct folio *folio, struct list_head *list);
int replace_free_hugepage_folios(unsigned long start_pfn, unsigned long end_pfn);
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 5a6fb301d9d0..89ec1e991dc5 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3152,11 +3152,6 @@ static void __init hugetlb_folio_init_vmemmap(struct folio *folio,
prep_compound_head(&folio->page, huge_page_order(h));
}

-static bool __init hugetlb_bootmem_page_prehvo(struct huge_bootmem_page *m)
-{
- return m->flags & HUGE_BOOTMEM_HVO;
-}
-
static bool __init hugetlb_bootmem_page_earlycma(struct huge_bootmem_page *m)
{
return m->flags & HUGE_BOOTMEM_CMA;
@@ -3248,12 +3243,7 @@ static void __init gather_bootmem_prealloc_node(unsigned long nid)
HUGETLB_VMEMMAP_RESERVE_PAGES);
init_new_hugetlb_folio(folio);

- if (hugetlb_bootmem_page_prehvo(m))
- /*
- * If pre-HVO was done, just set the
- * flag, the HVO code will then skip
- * this folio.
- */
+ if (section_vmemmap_optimizable(__pfn_to_section(folio_pfn(folio))))
folio_set_hugetlb_vmemmap_optimized(folio);
section_set_order_range(folio_pfn(folio), folio_nr_pages(folio), 0);

diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index b518c2c907f7..e3a200d98389 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -717,8 +717,6 @@ void __init hugetlb_vmemmap_optimize_bootmem_page(struct huge_bootmem_page *m)
return;

section_set_order_range(pfn, pages_per_huge_page(h), huge_page_order(h));
- if (section_vmemmap_optimizable(__pfn_to_section(pfn)))
- m->flags |= HUGE_BOOTMEM_HVO;
}

static const struct ctl_table hugetlb_vmemmap_sysctls[] = {
--
2.54.0