x86/mm: consolidate initmem_init()
PATCH 1/1 x86/mm: consolidate initmem_init()
From: "Mike Rapoport (Microsoft)" <[email protected]>
There are 4 wariants of initmem_init(), for 32 and 64 bits and for CONFIG_NUMA enabled and disabled.
After commit bbeb69ce3013 ("x86/mm: Remove CONFIG_HIGHMEM64G support") NUMA is not supported on 32 bits and arch/x86/mm/numa_32.c can be just deleted and setup_bootmem_allocator() with completely misleading name can be folded into initmem_init().
For 64 bits the NUMA variant calls x86_numa_init() and !NUMA variant sets all memory to node 0. The later can be split out into inline helper called x86_numa_init() and then both initmem_init() functions become the same.
Split out memblock_set_node() from initmem_init() for !NUMA on 64 bit into x86_numa_init() helper and remove arch/x86/mm/numa_*.c that only contained initmem_init() variants for NUMA configs.
--- arch/x86/include/asm/page_32_types.h | 1 - arch/x86/mm/Makefile | 2 +- arch/x86/mm/init_32.c | 7 ---- arch/x86/mm/init_64.c | 7 +++- arch/x86/mm/mm_internal.h | 4 ++ arch/x86/mm/numa.c | 3 +- arch/x86/mm/numa_32.c | 61 ---------------------------- arch/x86/mm/numa_64.c | 13 ------ arch/x86/mm/numa_internal.h | 10 ----- 9 files changed, 13 insertions(+), 95 deletions(-) delete mode 100644 arch/x86/mm/numa_32.c delete mode 100644 arch/x86/mm/numa_64.c delete mode 100644 arch/x86/mm/numa_internal.h
arch/x86/include/asm/page_32_types.h +0 -1
@@ -73,7 +73,6 @@ extern unsigned int __VMALLOC_RESERVE;extern int sysctl_legacy_va_layout;extern void find_low_pfn_range (void ); -extern void setup_bootmem_allocator (void );#endif /* !__ASSEMBLER__ */
arch/x86/mm/Makefile +1 -1
@@ -52,7 +52,7 @@ obj-$(CONFIG_MMIOTRACE) += mmiotrace.o mmiotrace-y := kmmio.o pf_in.o mmio-mod.o obj-$(CONFIG_MMIOTRACE_TEST) += testmmiotrace.o -obj-$(CONFIG_NUMA) += numa.o numa_$(BITS).o +obj-$(CONFIG_NUMA) += numa.o obj-$(CONFIG_AMD_NUMA) += amdtopology.o obj-$(CONFIG_ACPI_NUMA) += srat.o
arch/x86/mm/init_32.c +0 -7
@@ -612,7 +612,6 @@ void __init find_low_pfn_range(void)highmem_pfn_init (); } -#ifndef CONFIG_NUMA void __init initmem_init (void ) {#ifdef CONFIG_HIGHMEM
@@ -633,12 +632,6 @@ void __init initmem_init(void)printk (KERN_NOTICE "%ldMB LOWMEM available.\n" ,pages_to_mb (max_low_pfn)); - setup_bootmem_allocator(); -} -#endif /* !CONFIG_NUMA */ - -void __init setup_bootmem_allocator (void ) -{printk (KERN_INFO " mapped low ram: 0 - %08lx\n" , max_pfn_mapped<<PAGE_SHIFT );printk (KERN_INFO " low ram: 0 - %08lx\n" , max_low_pfn<<PAGE_SHIFT );
arch/x86/mm/init_64.c +6 -1
@@ -805,12 +805,17 @@ kernel_physical_mapping_change(unsigned long paddr_start, }#ifndef CONFIG_NUMA -void __init initmem_init (void ) +static inline void x86_numa_init (void ) {memblock_set_node (0 ,PHYS_ADDR_MAX , &memblock.memory,0 ); }#endif +void __init initmem_init (void ) +{ +x86_numa_init (); +} +void __init paging_init (void ) {sparse_init ();
arch/x86/mm/mm_internal.h +4 -0
@@ -25,4 +25,8 @@ void update_cache_mode_entry(unsigned entry, enum page_cache_mode cache);extern unsigned long tlb_single_page_flush_ceiling; +#ifdef CONFIG_NUMA +void __init x86_numa_init (void ); +#endif +#endif /* __X86_MM_INTERNAL_H */
arch/x86/mm/numa.c +2 -1
@@ -19,8 +19,9 @@#include <asm/proto.h> #include <asm/dma.h> #include <asm/amd_nb.h> +#include <asm/numa.h> -#include "numa_internal.h" +#include "mm_internal.h" int numa_off;
arch/x86/mm/numa_32.c deleted +0 -61
61 lines not on this page · raw message
arch/x86/mm/numa_64.c deleted +0 -13
@@ -1,13 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* -* Generic VM initialization for x86-64 NUMA setups. -* Copyright 2002,2003 Andi Kleen, SuSE Labs. -*/ -#include <linux/memblock.h> - -#include "numa_internal.h" - -void __init initmem_init (void ) -{ -x86_numa_init (); -}
arch/x86/mm/numa_internal.h deleted +0 -10
@@ -1,10 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __X86_MM_NUMA_INTERNAL_H -#define __X86_MM_NUMA_INTERNAL_H - -#include <linux/types.h> -#include <asm/numa.h> - -void __init x86_numa_init (void ); - -#endif /* __X86_MM_NUMA_INTERNAL_H */
base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
Signature · 1 line
2.47.2
[tip: x86/mm] x86/mm: Consolidate initmem_init()
The following commit has been merged into the x86/mm branch of tip:
The following commit has been merged into the x86/mm branch of tip:
Commit-ID: 35c3151a98a6e6f56552cff8dc7d59e8ef7aca50 Gitweb: https://git.kernel.org/tip/35c3151a98a6e6f56552cff8dc7d59e8ef7aca50 Author: Mike Rapoport (Microsoft) <[email protected]> AuthorDate: Wed, 09 Apr 2025 15:28:15 +03:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Wed, 09 Apr 2025 22:02:30 +02:00
x86/mm: Consolidate initmem_init()
There are 4 wariants of initmem_init(), for 32 and 64 bits and for CONFIG_NUMA enabled and disabled.
After commit bbeb69ce3013 ("x86/mm: Remove CONFIG_HIGHMEM64G support") NUMA is not supported on 32 bit kernels anymore, and arch/x86/mm/numa_32.c can be just deleted and setup_bootmem_allocator() with completely misleading name can be folded into initmem_init().
For 64 bits the NUMA variant calls x86_numa_init() and !NUMA variant sets all memory to node 0. The later can be split out into inline helper called x86_numa_init() and then both initmem_init() functions become the same.
Split out memblock_set_node() from initmem_init() for !NUMA on 64 bit into x86_numa_init() helper and remove arch/x86/mm/numa_*.c that only contained initmem_init() variants for NUMA configs.
--- arch/x86/include/asm/page_32_types.h | 1 +- arch/x86/mm/Makefile | 2 +- arch/x86/mm/init_32.c | 7 +--- arch/x86/mm/init_64.c | 7 ++- arch/x86/mm/mm_internal.h | 4 ++- arch/x86/mm/numa.c | 3 +- arch/x86/mm/numa_32.c | 61 +--------------------------- arch/x86/mm/numa_64.c | 13 +------ arch/x86/mm/numa_internal.h | 10 +---- 9 files changed, 13 insertions(+), 95 deletions(-) delete mode 100644 arch/x86/mm/numa_32.c delete mode 100644 arch/x86/mm/numa_64.c delete mode 100644 arch/x86/mm/numa_internal.h
arch/x86/include/asm/page_32_types.h +0 -1
@@ -73,7 +73,6 @@ extern unsigned int __VMALLOC_RESERVE;extern int sysctl_legacy_va_layout;extern void find_low_pfn_range (void ); -extern void setup_bootmem_allocator (void );#endif /* !__ASSEMBLER__ */
arch/x86/mm/Makefile +1 -1
@@ -52,7 +52,7 @@ obj-$(CONFIG_MMIOTRACE) += mmiotrace.o mmiotrace-y := kmmio.o pf_in.o mmio-mod.o obj-$(CONFIG_MMIOTRACE_TEST) += testmmiotrace.o -obj-$(CONFIG_NUMA) += numa.o numa_$(BITS).o +obj-$(CONFIG_NUMA) += numa.o obj-$(CONFIG_AMD_NUMA) += amdtopology.o obj-$(CONFIG_ACPI_NUMA) += srat.o
arch/x86/mm/init_32.c +0 -7
@@ -612,7 +612,6 @@ void __init find_low_pfn_range(void)highmem_pfn_init (); } -#ifndef CONFIG_NUMA void __init initmem_init (void ) {#ifdef CONFIG_HIGHMEM
@@ -633,12 +632,6 @@ void __init initmem_init(void)printk (KERN_NOTICE "%ldMB LOWMEM available.\n" ,pages_to_mb (max_low_pfn)); - setup_bootmem_allocator(); -} -#endif /* !CONFIG_NUMA */ - -void __init setup_bootmem_allocator (void ) -{printk (KERN_INFO " mapped low ram: 0 - %08lx\n" , max_pfn_mapped<<PAGE_SHIFT );printk (KERN_INFO " low ram: 0 - %08lx\n" , max_low_pfn<<PAGE_SHIFT );
arch/x86/mm/init_64.c +6 -1
@@ -805,12 +805,17 @@ kernel_physical_mapping_change(unsigned long paddr_start, }#ifndef CONFIG_NUMA -void __init initmem_init (void ) +static inline void x86_numa_init (void ) {memblock_set_node (0 ,PHYS_ADDR_MAX , &memblock.memory,0 ); }#endif +void __init initmem_init (void ) +{ +x86_numa_init (); +} +void __init paging_init (void ) {sparse_init ();
arch/x86/mm/mm_internal.h +4 -0
@@ -25,4 +25,8 @@ void update_cache_mode_entry(unsigned entry, enum page_cache_mode cache);extern unsigned long tlb_single_page_flush_ceiling; +#ifdef CONFIG_NUMA +void __init x86_numa_init (void ); +#endif +#endif /* __X86_MM_INTERNAL_H */
arch/x86/mm/numa.c +2 -1
@@ -19,8 +19,9 @@#include <asm/proto.h> #include <asm/dma.h> #include <asm/amd_nb.h> +#include <asm/numa.h> -#include "numa_internal.h" +#include "mm_internal.h" int numa_off;
arch/x86/mm/numa_32.c deleted +0 -61
61 lines not on this page · raw message
arch/x86/mm/numa_64.c deleted +0 -13
@@ -1,13 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* -* Generic VM initialization for x86-64 NUMA setups. -* Copyright 2002,2003 Andi Kleen, SuSE Labs. -*/ -#include <linux/memblock.h> - -#include "numa_internal.h" - -void __init initmem_init (void ) -{ -x86_numa_init (); -}
arch/x86/mm/numa_internal.h deleted +0 -10
@@ -1,10 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __X86_MM_NUMA_INTERNAL_H -#define __X86_MM_NUMA_INTERNAL_H - -#include <linux/types.h> -#include <asm/numa.h> - -void __init x86_numa_init (void ); - -#endif /* __X86_MM_NUMA_INTERNAL_H */