summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuchun Song <songmuchun@bytedance.com>2026-09-10 14:32:41 +0800
committerAndrew Morton <akpm@linux-foundation.org>2026-10-06 17:38:48 -0700
commit5e72deef11ba2d9110e3e4f1d9b2edf9e46495bb (patch)
tree31ff136ce65aa79925150b1fd8a6c7e8532e959a
parent48070b721a60c29c5a801cee8b9053c729e71eca (diff)
mm/sparse-vmemmap: rename HVO order macros
The macros VMEMMAP_TAIL_MIN_ORDER and NR_VMEMMAP_TAILS describe the order range where HVO can be applied, but their names tie that range to the tail-page cache implementation. Rename them with a VMEMMAP_OPTIMIZATION prefix and use the new names in the HVO paths. This makes the code describe the optimization requirements rather than the tail-page cache implementation detail. No functional change intended. Link: https://lore.kernel.org/20260910063256.64386-3-songmuchun@bytedance.com Signed-off-by: Muchun Song <songmuchun@bytedance.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Acked-by: Qi Zheng <qi.zheng@linux.dev> Cc: David Hildenbrand (Arm) <david@kernel.org> Cc: David Laight <david.laight.linux@gmail.com> Cc: Liam R. Howlett <liam@infradead.org> Cc: Lorenzo Stoakes <ljs@kernel.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Oscar Salvador <osalvador@suse.de> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Vlastimil Babka <vbabka@kernel.org>
-rw-r--r--include/linux/mmzone.h17
-rw-r--r--mm/hugetlb.c4
-rw-r--r--mm/hugetlb_vmemmap.c2
-rw-r--r--mm/sparse-vmemmap.c4
4 files changed, 14 insertions, 13 deletions
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 0a2428714108..5fb9b37819d5 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -107,13 +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)
+/* The number of struct pages covered by the retained vmemmap pages with HVO enabled. */
+#define VMEMMAP_OPTIMIZATION_NR_STRUCT_PAGES (PAGE_SIZE / sizeof(struct page))
+#define VMEMMAP_OPTIMIZATION_MIN_ORDER (ilog2(VMEMMAP_OPTIMIZATION_NR_STRUCT_PAGES) + 1)
+
+#define __VMEMMAP_OPTIMIZATION_NR_ORDERS \
+ (MAX_FOLIO_ORDER - VMEMMAP_OPTIMIZATION_MIN_ORDER + 1)
+#define VMEMMAP_OPTIMIZATION_NR_ORDERS \
+ (__VMEMMAP_OPTIMIZATION_NR_ORDERS > 0 ? __VMEMMAP_OPTIMIZATION_NR_ORDERS : 0)
enum migratetype {
MIGRATE_UNMOVABLE,
@@ -1158,7 +1159,7 @@ struct zone {
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];
+ struct page *vmemmap_tails[VMEMMAP_OPTIMIZATION_NR_ORDERS];
#endif
} ____cacheline_internodealigned_in_smp;
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index e645d2d25bb6..b2aa988979e9 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3357,7 +3357,7 @@ void __init hugetlb_bootmem_struct_page_init(void)
struct zone *zone;
for_each_zone(zone) {
- for (int i = 0; i < NR_VMEMMAP_TAILS; i++) {
+ for (int i = 0; i < VMEMMAP_OPTIMIZATION_NR_ORDERS; i++) {
struct page *tail, *p;
unsigned int order;
@@ -3365,7 +3365,7 @@ void __init hugetlb_bootmem_struct_page_init(void)
if (!tail)
continue;
- order = i + VMEMMAP_TAIL_MIN_ORDER;
+ order = i + VMEMMAP_OPTIMIZATION_MIN_ORDER;
p = page_to_virt(tail);
/*
* prep_and_add_bootmem_folios() can access pageblock
diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index 917db0984143..ae8fdaa42118 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -494,7 +494,7 @@ static bool vmemmap_should_optimize_folio(const struct hstate *h, struct folio *
static struct page *vmemmap_get_tail(unsigned int order, struct zone *zone)
{
- const unsigned int idx = order - VMEMMAP_TAIL_MIN_ORDER;
+ const unsigned int idx = order - VMEMMAP_OPTIMIZATION_MIN_ORDER;
struct page *tail, *p;
int node = zone_to_nid(zone);
diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
index 5a2469fb1838..aa6a4a2fae98 100644
--- a/mm/sparse-vmemmap.c
+++ b/mm/sparse-vmemmap.c
@@ -329,12 +329,12 @@ static __meminit struct page *vmemmap_get_tail(unsigned int order, struct zone *
unsigned int idx;
int node = zone_to_nid(zone);
- if (WARN_ON_ONCE(order < VMEMMAP_TAIL_MIN_ORDER))
+ if (WARN_ON_ONCE(order < VMEMMAP_OPTIMIZATION_MIN_ORDER))
return NULL;
if (WARN_ON_ONCE(order > MAX_FOLIO_ORDER))
return NULL;
- idx = order - VMEMMAP_TAIL_MIN_ORDER;
+ idx = order - VMEMMAP_OPTIMIZATION_MIN_ORDER;
tail = zone->vmemmap_tails[idx];
if (tail)
return tail;