Hi Mike, > > Add a config option THP_HUGE_ZERO_PAGE_ALWAYS that will always allocate > > the huge_zero_folio, and it will never be freed. This makes using the > > huge_zero_folio without having to pass any mm struct and a call to put_folio > > in the destructor. > > I don't think this config option should be tied to THP. It's perfectly > sensible to have a configuration with HUGETLB and without THP. > Hmm, that makes sense. You mean something like this (untested): diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 2e1527580746..d447a9b9eb7d 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -151,8 +151,8 @@ config X86 select ARCH_WANT_OPTIMIZE_DAX_VMEMMAP if X86_64 select ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP if X86_64 select ARCH_WANT_HUGETLB_VMEMMAP_PREINIT if X86_64 + select ARCH_WANTS_HUGE_ZERO_PAGE_ALWAYS if X86_64 select ARCH_WANTS_THP_SWAP if X86_64 - select ARCH_WANTS_THP_ZERO_PAGE_ALWAYS if X86_64 select ARCH_HAS_PARANOID_L1D_FLUSH select BUILDTIME_TABLE_SORT select CLKEVT_I8253 diff --git a/mm/Kconfig b/mm/Kconfig index a2994e7d55ba..83a5b95a2286 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -823,9 +823,19 @@ config ARCH_WANT_GENERAL_HUGETLB config ARCH_WANTS_THP_SWAP def_bool n -config ARCH_WANTS_THP_ZERO_PAGE_ALWAYS +config ARCH_WANTS_HUGE_ZERO_PAGE_ALWAYS def_bool n +config HUGE_ZERO_PAGE_ALWAYS + def_bool y + depends on HUGETLB_PAGE && ARCH_WANTS_HUGE_ZERO_PAGE_ALWAYS + help + Typically huge_zero_folio, which is a huge 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. + + config MM_ID def_bool n @@ -898,15 +908,6 @@ config READ_ONLY_THP_FOR_FS support of file THPs will be developed in the next few release cycles. -config THP_ZERO_PAGE_ALWAYS - def_bool y - depends on TRANSPARENT_HUGEPAGE && ARCH_WANTS_THP_ZERO_PAGE_ALWAYS - help - Typically huge_zero_folio, which is a THP 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. - config NO_PAGE_MAPCOUNT bool "No per-page mapcount (EXPERIMENTAL)" help -- Pankaj