[PATCH 9/9] mm: vmalloc: Scale and activate cvz_size
From: Uladzislau Rezki (Sony)
Date: Mon May 22 2023 - 07:15:10 EST
Scale a zone size to number of CPUs. Each power of two
value adds extra 100 * PAGE_SIZE bytes to a zone size.
A maximum zone size limit is set to 4M, it is reached
if number of CPUs=1024 and PAGE_SIZE=4096 bytes.
For 32-bit or single core systems cvz_size is set to
ULONG_MAX. It means that a pre-loading technique is
deactivated.
Signed-off-by: Uladzislau Rezki (Sony) <urezki@xxxxxxxxx>
---
mm/vmalloc.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 8054b8bf6c18..a5e6956a8da4 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -806,8 +806,6 @@ struct cpu_vmap_zone {
};
static DEFINE_PER_CPU(struct cpu_vmap_zone, cpu_vmap_zone);
-
-/* Disable a per-cpu caching. */
static __read_mostly unsigned long cvz_size = ULONG_MAX;
static inline unsigned int
@@ -4490,6 +4488,19 @@ static void vmap_init_pcpu_zones(void)
spin_lock_init(&z->fbl[j].lock);
}
}
+
+ /*
+ * Scale a zone size to number of CPUs. Each power of two
+ * value adds extra 100 pages to a zone size. A high-threshold
+ * limit is set to 4M. It can be reached if number of CPUs=1024
+ * whereas a PAGE_SIZE is 4096 bytes.
+ */
+#if BITS_PER_LONG == 64
+ if (i > 1) {
+ cvz_size = fls(i) * (100 * PAGE_SIZE);
+ cvz_size = min(cvz_size, (unsigned long) SZ_4M);
+ }
+#endif
}
void __init vmalloc_init(void)
--
2.30.2