mm-hugetlb-remove-fake-head-pages.patch removed from -mm tree
The quilt patch titled
Subject: mm/hugetlb: remove fake head pages
has been removed from the -mm tree. Its filename was
mm-hugetlb-remove-fake-head-pages.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Kiryl Shutsemau <[email protected]>
Subject: mm/hugetlb: remove fake head pages
Date: Fri, 27 Feb 2026 19:42:50 +0000
HugeTLB Vmemmap Optimization (HVO) reduces memory usage by freeing most vmemmap pages for huge pages and remapping the freed range to a single page containing the struct page metadata.
With the new mask-based compound_info encoding (for power-of-2 struct page sizes), all tail pages of the same order are now identical regardless of which compound page they belong to. This means the tail pages can be truly shared without fake heads.
Allocate a single page of initialized tail struct pages per zone per order in the vmemmap_tails[] array in struct zone. All huge pages of that order in the zone share this tail page, mapped read-only into their vmemmap. The head page remains unique per huge page.
Redefine MAX_FOLIO_ORDER using ilog2(). The define has to produce a compile-constant as it is used to specify vmemmap_tail array size. For some reason, compiler is not able to solve get_order() at compile-time, but ilog2() works.
Avoid PUD_ORDER to define MAX_FOLIO_ORDER as it adds dependency to <linux/pgtable.h> which generates hard-to-break include loop.
This eliminates fake heads while maintaining the same memory savings, and simplifies compound_head() by removing fake head detection.
---
include/linux/mm.h | 3 + include/linux/mmzone.h | 19 +++++++++- mm/hugetlb_vmemmap.c | 73 +++++++++++++++++++++++++++++++++++++-- mm/internal.h | 9 ++++ mm/sparse-vmemmap.c | 55 +++++++++++++++++++++++++---- 5 files changed, 145 insertions(+), 14 deletions(-)
include/linux/mm.h renamed from include/linux/mm.h~mm-hugetlb-remove-fake-head-pages +2 -1
@@ -4472,7 +4472,8 @@ int vmemmap_populate_hugepages(unsigned int node, struct vmem_altmap *altmap);int vmemmap_populate (unsigned long start,unsigned long end,int node,struct vmem_altmap *altmap); -int vmemmap_populate_hvo (unsigned long start,unsigned long end,int node, +int vmemmap_populate_hvo (unsigned long start,unsigned long end, +unsigned int order,struct zone *zone,unsigned long headsize);void vmemmap_wrprotect_hvo (unsigned long start,unsigned long end,int node,unsigned long headsize);
include/linux/mmzone.h renamed from include/linux/mmzone.h~mm-hugetlb-remove-fake-head-pages +17 -2
@@ -81,13 +81,17 @@* currently expect (see CONFIG_HAVE_GIGANTIC_FOLIOS): with hugetlb, we expect * no folios larger than 16 GiB on 64bit and 1 GiB on 32bit. */ -#define MAX_FOLIO_ORDER get_order(IS_ENABLED(CONFIG_64BIT) ? SZ_16G : SZ_1G) +#ifdef CONFIG_64BIT +#define MAX_FOLIO_ORDER (ilog2(SZ_16G) - PAGE_SHIFT) +#else +#define MAX_FOLIO_ORDER (ilog2(SZ_1G) - PAGE_SHIFT) +#endif #else /* * Without hugetlb, gigantic folios that are bigger than a single PUD are * currently impossible. */ -#define MAX_FOLIO_ORDER PUD_ORDER +#define MAX_FOLIO_ORDER (PUD_SHIFT - PAGE_SHIFT)#endif #define MAX_FOLIO_NR_PAGES (1UL << MAX_FOLIO_ORDER)
@@ -103,6 +107,14 @@ is_power_of_2(sizeof(struct page)) ? \ MAX_FOLIO_NR_PAGES * sizeof(struct page) : 0) +/* +* vmemmap optimization (like HVO) is only possible for page orders that fill +* two or more pages with struct pages. +*/ +#define VMEMMAP_TAIL_MIN_ORDER (ilog2(2 * PAGE_SIZE / sizeof(struct page))) +#define __NR_VMEMMAP_TAILS (MAX_FOLIO_ORDER - VMEMMAP_TAIL_MIN_ORDER + 1) +#define NR_VMEMMAP_TAILS (__NR_VMEMMAP_TAILS > 0 ? __NR_VMEMMAP_TAILS : 0) +enum migratetype {MIGRATE_UNMOVABLE ,MIGRATE_MOVABLE ,
@@ -1113,6 +1125,9 @@ struct zone {/* Zone statistics */ atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS ];atomic_long_t vm_numa_event[NR_VM_NUMA_EVENT_ITEMS ]; +#ifdef CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP +struct page *vmemmap_tails[NR_VMEMMAP_TAILS ]; +#endif }____cacheline_internodealigned_in_smp ;enum pgdat_flags {
mm/hugetlb_vmemmap.c renamed from mm/hugetlb_vmemmap.c~mm-hugetlb-remove-fake-head-pages +70 -3
130 lines not on this page · raw message
mm/internal.h renamed from mm/internal.h~mm-hugetlb-remove-fake-head-pages +9 -0
@@ -905,6 +905,15 @@ static inline void prep_compound_tail(stset_page_private (tail,0 ); } +static inline void init_compound_tail (struct page *tail, +const struct page *head,unsigned int order,struct zone *zone) +{ +atomic_set (&tail->_mapcount,-1 ); +set_page_node (tail,zone_to_nid (zone)); +set_page_zone (tail,zone_idx (zone)); +prep_compound_tail (tail, head, order); +} +void post_alloc_hook (struct page *page,unsigned int order,gfp_t gfp_flags);extern bool free_pages_prepare (struct page *page,unsigned int order);
mm/sparse-vmemmap.c renamed from mm/sparse-vmemmap.c~mm-hugetlb-remove-fake-head-pages +47 -8
71 lines not on this page · raw message
_
Patches currently in -mm which might be from [email protected] are