The boot message reports the potential vmemmap savings for each HugeTLB page size. It is a static estimate and does not indicate whether HVO is enabled or how much vmemmap memory is actually in use. Users can query vm.hugetlb_optimize_vmemmap for the HVO enable policy and inspect nr_memmap_pages and nr_memmap_boot_pages in /proc/vmstat for the actual vmemmap usage. Remove the boot message and hugetlb_vmemmap_optimizable_size(), which is only used to calculate the reported estimate. Signed-off-by: Muchun Song Reviewed-by: Lance Yang --- v2: - Make the !CONFIG_HUGETLB_PAGE huge_page_order() stub const-correct (reported by Sashiko) - Collect Reviewed-by from Lance Yang --- include/linux/hugetlb.h | 4 ++-- mm/hugetlb.c | 2 -- mm/hugetlb_vmemmap.h | 27 ++++----------------------- 3 files changed, 6 insertions(+), 27 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index aea18895e145..14af4396de7e 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -814,7 +814,7 @@ static inline unsigned long huge_page_mask(struct hstate *h) return h->mask; } -static inline unsigned int huge_page_order(struct hstate *h) +static inline unsigned int huge_page_order(const struct hstate *h) { return h->order; } @@ -1233,7 +1233,7 @@ static inline unsigned long huge_page_mask(struct hstate *h) return PAGE_MASK; } -static inline unsigned int huge_page_order(struct hstate *h) +static inline unsigned int huge_page_order(const struct hstate *h) { return 0; } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 6a4af46ddded..688854ac732e 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3759,8 +3759,6 @@ static void __init report_hugepages(void) string_get_size(huge_page_size(h), 1, STRING_UNITS_2, buf, sizeof(buf)); pr_info("registered %s page size, pre-allocated %ld pages\n", buf, h->nr_huge_pages); - pr_info("%d KiB vmemmap can be freed for a %s page\n", - hugetlb_vmemmap_optimizable_size(h) / SZ_1K, buf); } } diff --git a/mm/hugetlb_vmemmap.h b/mm/hugetlb_vmemmap.h index 8b28063d78cc..b7781baa2ce0 100644 --- a/mm/hugetlb_vmemmap.h +++ b/mm/hugetlb_vmemmap.h @@ -33,23 +33,6 @@ static inline void hugetlb_vmemmap_write_unlock(void) up_write(&vmemmap_remap_rwsem); } -static inline unsigned int hugetlb_vmemmap_size(const struct hstate *h) -{ - return pages_per_huge_page(h) * sizeof(struct page); -} - -/* - * Return how many vmemmap size associated with a HugeTLB page that can be - * optimized and can be freed to the buddy allocator. - */ -static inline unsigned int hugetlb_vmemmap_optimizable_size(const struct hstate *h) -{ - int size = hugetlb_vmemmap_size(h) - VMEMMAP_OPTIMIZATION_SIZE; - - if (!is_power_of_2(sizeof(struct page))) - return 0; - return size > 0 ? size : 0; -} #else static inline int hugetlb_vmemmap_restore_folio(const struct hstate *h, struct folio *folio) { @@ -80,11 +63,6 @@ static inline void hugetlb_vmemmap_write_unlock(void) { } -static inline unsigned int hugetlb_vmemmap_optimizable_size(const struct hstate *h) -{ - return 0; -} - static inline void hugetlb_vmemmap_optimize_bootmem_page(unsigned long pfn, unsigned int order) { } @@ -95,6 +73,9 @@ DEFINE_LOCK_GUARD_0(vmemmap_remap, static inline bool hugetlb_vmemmap_optimizable(const struct hstate *h) { - return hugetlb_vmemmap_optimizable_size(h) != 0; + if (!IS_ENABLED(CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP)) + return false; + + return vmemmap_optimizable_order(huge_page_order(h)); } #endif /* _LINUX_HUGETLB_VMEMMAP_H */ -- 2.54.0