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 <[email protected]>
---
 include/linux/hugetlb.h |  5 ++---
 include/linux/mmzone.h  |  7 ++++++-
 mm/hugetlb.c            | 12 +-----------
 mm/hugetlb_vmemmap.c    |  2 --
 4 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index dce8969961ea..18af8f304b95 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -695,9 +695,8 @@ struct huge_bootmem_page {
        unsigned long flags;
 };
 
-#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/include/linux/mmzone.h b/include/linux/mmzone.h
index a60fd5785fa5..9b87d798a365 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -117,6 +117,11 @@
 #define NR_OPTIMIZABLE_FOLIO_ORDERS            \
        (__NR_OPTIMIZABLE_FOLIO_ORDERS > 0 ? __NR_OPTIMIZABLE_FOLIO_ORDERS : 0)
 
+static inline bool order_vmemmap_optimizable(unsigned int order)
+{
+       return order >= OPTIMIZABLE_FOLIO_MIN_ORDER;
+}
+
 enum migratetype {
        MIGRATE_UNMOVABLE,
        MIGRATE_MOVABLE,
@@ -2262,7 +2267,7 @@ static inline bool section_vmemmap_optimizable(const 
struct mem_section *section
        if (!is_power_of_2(sizeof(struct page)))
                return false;
 
-       return section_order(section) >= OPTIMIZABLE_FOLIO_MIN_ORDER;
+       return order_vmemmap_optimizable(section_order(section));
 }
 
 #ifndef CONFIG_HAVE_ARCH_PFN_VALID
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 080f130017e3..abd79bb85b1c 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3169,11 +3169,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;
@@ -3265,12 +3260,7 @@ static void __init gather_bootmem_prealloc_node(unsigned 
long nid)
                                           
OPTIMIZED_FOLIO_VMEMMAP_NR_STRUCT_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 
(order_vmemmap_optimizable(pfn_to_section_order(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 730190390ba9..66362e553870 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -718,8 +718,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


Reply via email to