On 27.05.25 20:00, Pankaj Raghav (Samsung) wrote:
On Tue, May 27, 2025 at 09:37:50AM -0700, Dave Hansen wrote:
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 055204dc211d..96f99b4f96ea 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -152,6 +152,7 @@ config X86
select ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP if X86_64
select ARCH_WANT_HUGETLB_VMEMMAP_PREINIT if X86_64
select ARCH_WANTS_THP_SWAP if X86_64
+ select ARCH_WANTS_STATIC_PMD_ZERO_PAGE if X86_64
I don't think this should be the default. There are lots of little
x86_64 VMs sitting around and 2MB might be significant to them.
This is the feedback I wanted. I will make it optional.
+config ARCH_WANTS_STATIC_PMD_ZERO_PAGE
+ bool
+
+config STATIC_PMD_ZERO_PAGE
+ def_bool y
+ depends on ARCH_WANTS_STATIC_PMD_ZERO_PAGE
+ help
+ Typically huge_zero_folio, which is a PMD page of zeroes, is allocated
+ on demand and deallocated when not in use. This option will always
+ allocate huge_zero_folio for zeroing and it is never deallocated.
+ Not suitable for memory constrained systems.
"Static" seems like a weird term to use for this. I was really expecting
to see a 2MB object that gets allocated in .bss or something rather than
a dynamically allocated page that's just never freed.
My first proposal was along those lines[0] (sorry I messed up version
while sending the patches). David Hilderbrand suggested to leverage the
infrastructure we already have in huge_memory.
Sorry, maybe I was not 100% clear.
We could either
a) Allocate it statically in bss and reuse it for huge_memory purposes
(static vs. dynamic is a good fit)
b) Allocate it during early boot and never free it.
Assuming we allocate it from memblock, it's almost static ... :)
I would not allocate it at runtime later when requested. Then, "static"
is really a suboptimal fit.
--
Cheers,
David / dhildenb