Skip to contentSkip to conversation

mm: make SPARSEMEM_VMEMMAP_PREINIT an internal option

PATCH In review Frank van der Linden 3 participants 6 messages Feb 27, 2025 – Feb 28, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: make SPARSEMEM_VMEMMAP_PREINIT an internal option

SPARSEMEM_VMEMMAP_PREINIT is not useful as a user-facing option, it is just something that should be selected if a subsystem wishes to do vmemmap preinit. That's currently only HUGETLB_PAGE_OPTIMIZE_VMEMMAP.

So, make it a default-less option that is only selected by HUGETLB_PAGE_OPTIMIZE_VMEMMAP, iff the architecture has noted it is capable of doing hugetlb vmemmap preinit. That is done via ARCH_WANT_HUGETLB_VMEMMAP_PREINIT, renamed from ARCH_WANT_SPARSE_VMEMMAP_PREINIT.

Fixes a916062fdd134 ("mm/sparse: allow for alternate vmemmap section init at boot")
Cc Johannes Weiner <[email protected]>
---
 arch/x86/Kconfig | 2 +-
 fs/Kconfig       | 1 +
 mm/Kconfig       | 9 ++++-----
 3 files changed, 6 insertions(+), 6 deletions(-)
arch/x86/Kconfig +1 -1
index 541347a6fa81..d05f26e301a9 100644
@@ -147,7 +147,7 @@ config X86
 	select ARCH_WANT_LD_ORPHAN_WARN
 	select ARCH_WANT_OPTIMIZE_DAX_VMEMMAP	if X86_64
 	select ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP	if X86_64
-	select ARCH_WANT_SPARSEMEM_VMEMMAP_PREINIT if X86_64
+	select ARCH_WANT_HUGETLB_VMEMMAP_PREINIT if X86_64
 	select ARCH_WANTS_THP_SWAP		if X86_64
 	select ARCH_HAS_PARANOID_L1D_FLUSH
 	select BUILDTIME_TABLE_SORT
fs/Kconfig +1 -0
index 64d420e3c475..8bcd3a6f80ab 100644
@@ -286,6 +286,7 @@ config HUGETLB_PAGE_OPTIMIZE_VMEMMAP
 	def_bool HUGETLB_PAGE
 	depends on ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP
 	depends on SPARSEMEM_VMEMMAP
+	select SPARSEMEM_VMEMMAP_PREINIT if ARCH_WANT_HUGETLB_VMEMMAP_PREINIT
 
 config HUGETLB_PMD_PAGE_TABLE_SHARING
 	def_bool HUGETLB_PAGE
mm/Kconfig +4 -5
index 2761098dbc1a..7262a145ed64 100644
@@ -443,13 +443,9 @@ config SPARSEMEM_VMEMMAP
 	  pfn_to_page and page_to_pfn operations.  This is the most
 	  efficient option when sufficient kernel resources are available.
 
-config ARCH_WANT_SPARSEMEM_VMEMMAP_PREINIT
+config SPARSEMEM_VMEMMAP_PREINIT
 	bool
 
-config SPARSEMEM_VMEMMAP_PREINIT
-	bool "Early init of sparse memory virtual memmap"
-	depends on SPARSEMEM_VMEMMAP && ARCH_WANT_SPARSEMEM_VMEMMAP_PREINIT
-	default y
 #
 # Select this config option from the architecture Kconfig, if it is preferred
 # to enable the feature of HugeTLB/dev_dax vmemmap optimization.
@@ -460,6 +456,9 @@ config ARCH_WANT_OPTIMIZE_DAX_VMEMMAP
 config ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP
 	bool
 
+config ARCH_WANT_HUGETLB_VMEMMAP_PREINIT
+	bool
+
 config HAVE_MEMBLOCK_PHYS_MAP
 	bool
 
Signature · 1 line
2.48.1.711.g2feabab25a-goog
#1 lore raw
Quoted 76 lines · Frank van der Linden

SPARSEMEM_VMEMMAP_PREINIT is not useful as a user-facing option, it is just something that should be selected if a subsystem wishes to do vmemmap preinit. That's currently only HUGETLB_PAGE_OPTIMIZE_VMEMMAP.

So, make it a default-less option that is only selected by HUGETLB_PAGE_OPTIMIZE_VMEMMAP, iff the architecture has noted it is capable of doing hugetlb vmemmap preinit. That is done via ARCH_WANT_HUGETLB_VMEMMAP_PREINIT, renamed from ARCH_WANT_SPARSE_VMEMMAP_PREINIT.

Fixes a916062fdd134 ("mm/sparse: allow for alternate vmemmap section init at boot")
Cc Johannes Weiner <[email protected]>
---
 arch/x86/Kconfig | 2 +-
 fs/Kconfig       | 1 +
 mm/Kconfig       | 9 ++++-----
 3 files changed, 6 insertions(+), 6 deletions(-)
arch/x86/Kconfig +1 -1
index 541347a6fa81..d05f26e301a9 100644
@@ -147,7 +147,7 @@ config X86
        select ARCH_WANT_LD_ORPHAN_WARN
        select ARCH_WANT_OPTIMIZE_DAX_VMEMMAP   if X86_64
        select ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP       if X86_64
-       select ARCH_WANT_SPARSEMEM_VMEMMAP_PREINIT if X86_64
+       select ARCH_WANT_HUGETLB_VMEMMAP_PREINIT if X86_64
        select ARCH_WANTS_THP_SWAP              if X86_64
        select ARCH_HAS_PARANOID_L1D_FLUSH
        select BUILDTIME_TABLE_SORT
fs/Kconfig +1 -0
index 64d420e3c475..8bcd3a6f80ab 100644
@@ -286,6 +286,7 @@ config HUGETLB_PAGE_OPTIMIZE_VMEMMAP
        def_bool HUGETLB_PAGE
        depends on ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP
        depends on SPARSEMEM_VMEMMAP
+       select SPARSEMEM_VMEMMAP_PREINIT if ARCH_WANT_HUGETLB_VMEMMAP_PREINIT
 
 config HUGETLB_PMD_PAGE_TABLE_SHARING
        def_bool HUGETLB_PAGE
mm/Kconfig +4 -6
index 2761098dbc1a..7262a145ed64 100644
@@ -443,13 +443,9 @@ config SPARSEMEM_VMEMMAP
          pfn_to_page and page_to_pfn operations.  This is the most
          efficient option when sufficient kernel resources are available.
 
-config ARCH_WANT_SPARSEMEM_VMEMMAP_PREINIT
+config SPARSEMEM_VMEMMAP_PREINIT
        bool
 
-config SPARSEMEM_VMEMMAP_PREINIT
-       bool "Early init of sparse memory virtual memmap"
-       depends on SPARSEMEM_VMEMMAP && ARCH_WANT_SPARSEMEM_VMEMMAP_PREINIT
-       default y
 #
 # Select this config option from the architecture Kconfig, if it is preferred
 # to enable the feature of HugeTLB/dev_dax vmemmap optimization.
@@ -460,6 +456,9 @@ config ARCH_WANT_OPTIMIZE_DAX_VMEMMAP
 config ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP
        bool
 
+config ARCH_WANT_HUGETLB_VMEMMAP_PREINIT
+       bool
+
 config HAVE_MEMBLOCK_PHYS_MAP
        bool
 
--
Quoted 2 lines

2.48.1.711.g2feabab25a-goog

Hm, this should actually be split in two patches, since the x86 change comes in a later patch in the original series.

Let me resend this in a v2 that contains two separate patches.

Sorry about the noise.

- Frank

#2 lore raw
Quoted 84 lines · Frank van der Linden
Quoted 76 lines · Frank van der Linden

SPARSEMEM_VMEMMAP_PREINIT is not useful as a user-facing option, it is just something that should be selected if a subsystem wishes to do vmemmap preinit. That's currently only HUGETLB_PAGE_OPTIMIZE_VMEMMAP.

So, make it a default-less option that is only selected by HUGETLB_PAGE_OPTIMIZE_VMEMMAP, iff the architecture has noted it is capable of doing hugetlb vmemmap preinit. That is done via ARCH_WANT_HUGETLB_VMEMMAP_PREINIT, renamed from ARCH_WANT_SPARSE_VMEMMAP_PREINIT.

Fixes a916062fdd134 ("mm/sparse: allow for alternate vmemmap section init at boot")
Cc Johannes Weiner <[email protected]>
---
 arch/x86/Kconfig | 2 +-
 fs/Kconfig       | 1 +
 mm/Kconfig       | 9 ++++-----
 3 files changed, 6 insertions(+), 6 deletions(-)
arch/x86/Kconfig +1 -1
index 541347a6fa81..d05f26e301a9 100644
@@ -147,7 +147,7 @@ config X86
        select ARCH_WANT_LD_ORPHAN_WARN
        select ARCH_WANT_OPTIMIZE_DAX_VMEMMAP   if X86_64
        select ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP       if X86_64
-       select ARCH_WANT_SPARSEMEM_VMEMMAP_PREINIT if X86_64
+       select ARCH_WANT_HUGETLB_VMEMMAP_PREINIT if X86_64
        select ARCH_WANTS_THP_SWAP              if X86_64
        select ARCH_HAS_PARANOID_L1D_FLUSH
        select BUILDTIME_TABLE_SORT
fs/Kconfig +1 -0
index 64d420e3c475..8bcd3a6f80ab 100644
@@ -286,6 +286,7 @@ config HUGETLB_PAGE_OPTIMIZE_VMEMMAP
        def_bool HUGETLB_PAGE
        depends on ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP
        depends on SPARSEMEM_VMEMMAP
+       select SPARSEMEM_VMEMMAP_PREINIT if ARCH_WANT_HUGETLB_VMEMMAP_PREINIT
 
 config HUGETLB_PMD_PAGE_TABLE_SHARING
        def_bool HUGETLB_PAGE
mm/Kconfig +4 -6
index 2761098dbc1a..7262a145ed64 100644
@@ -443,13 +443,9 @@ config SPARSEMEM_VMEMMAP
          pfn_to_page and page_to_pfn operations.  This is the most
          efficient option when sufficient kernel resources are available.
 
-config ARCH_WANT_SPARSEMEM_VMEMMAP_PREINIT
+config SPARSEMEM_VMEMMAP_PREINIT
        bool
 
-config SPARSEMEM_VMEMMAP_PREINIT
-       bool "Early init of sparse memory virtual memmap"
-       depends on SPARSEMEM_VMEMMAP && ARCH_WANT_SPARSEMEM_VMEMMAP_PREINIT
-       default y
 #
 # Select this config option from the architecture Kconfig, if it is preferred
 # to enable the feature of HugeTLB/dev_dax vmemmap optimization.
@@ -460,6 +456,9 @@ config ARCH_WANT_OPTIMIZE_DAX_VMEMMAP
 config ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP
        bool
 
+config ARCH_WANT_HUGETLB_VMEMMAP_PREINIT
+       bool
+
 config HAVE_MEMBLOCK_PHYS_MAP
        bool
 
--
Quoted 2 lines

2.48.1.711.g2feabab25a-goog

Hm, this should actually be split in two patches, since the x86 change comes in a later patch in the original series.

Quoted 5 lines

Let me resend this in a v2 that contains two separate patches.

Sorry about the noise.

- Frank

Actually, sending two fixes would make mm-unstable not bisectable. I'll just leave it at this one. If I send a v5 at some point, I can change the two commits individually.

- Frank

Acked-by on v1 1/1
#3 lore raw
In reply to Frank van der Linden
Quoted 11 lines · Frank van der Linden

SPARSEMEM_VMEMMAP_PREINIT is not useful as a user-facing option, it is just something that should be selected if a subsystem wishes to do vmemmap preinit. That's currently only HUGETLB_PAGE_OPTIMIZE_VMEMMAP.

So, make it a default-less option that is only selected by HUGETLB_PAGE_OPTIMIZE_VMEMMAP, iff the architecture has noted it is capable of doing hugetlb vmemmap preinit. That is done via ARCH_WANT_HUGETLB_VMEMMAP_PREINIT, renamed from ARCH_WANT_SPARSE_VMEMMAP_PREINIT.

Quoted 3 lines
Fixes a916062fdd134 ("mm/sparse: allow for alternate vmemmap section init at boot")
Cc Johannes Weiner <[email protected]>

Thank you!

maintainer
#4 lore raw
In reply to Frank van der Linden
Quoted 11 lines · On Thu, 27 Feb 2025 18:57:17 +0000 Frank van der Linden <[email protected]> wrote:

SPARSEMEM_VMEMMAP_PREINIT is not useful as a user-facing option, it is just something that should be selected if a subsystem wishes to do vmemmap preinit. That's currently only HUGETLB_PAGE_OPTIMIZE_VMEMMAP.

So, make it a default-less option that is only selected by HUGETLB_PAGE_OPTIMIZE_VMEMMAP, iff the architecture has noted it is capable of doing hugetlb vmemmap preinit. That is done via ARCH_WANT_HUGETLB_VMEMMAP_PREINIT, renamed from ARCH_WANT_SPARSE_VMEMMAP_PREINIT.

I'm in a mess getting this landed in the right place in the series. We seem to have a few updates in the works so I'll drop this series again.

And I'll disable Mike's "mm/mm_init: rename __init_reserved_page_zone to __init_page_from_nid" and "mm/mm_init: rename init_reserved_page to init_deferred_page" until "hugetlb/CMA improvements for large systems v5" appears.

#5 lore raw
Quoted 15 lines · Andrew Morton
Quoted 11 lines · On Thu, 27 Feb 2025 18:57:17 +0000 Frank van der Linden <[email protected]> wrote:

SPARSEMEM_VMEMMAP_PREINIT is not useful as a user-facing option, it is just something that should be selected if a subsystem wishes to do vmemmap preinit. That's currently only HUGETLB_PAGE_OPTIMIZE_VMEMMAP.

So, make it a default-less option that is only selected by HUGETLB_PAGE_OPTIMIZE_VMEMMAP, iff the architecture has noted it is capable of doing hugetlb vmemmap preinit. That is done via ARCH_WANT_HUGETLB_VMEMMAP_PREINIT, renamed from ARCH_WANT_SPARSE_VMEMMAP_PREINIT.

Quoted 7 lines

I'm in a mess getting this landed in the right place in the series. We seem to have a few updates in the works so I'll drop this series again.

And I'll disable Mike's "mm/mm_init: rename __init_reserved_page_zone to __init_page_from_nid" and "mm/mm_init: rename init_reserved_page to init_deferred_page" until "hugetlb/CMA improvements for large systems v5" appears.

I'll send a v5 shortly, which includes this fix, and the 32bit + snprintf warning fixes.

- Frank