]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/mm: Consolidate initmem_init()
authorMike Rapoport (Microsoft) <rppt@kernel.org>
Wed, 9 Apr 2025 12:28:15 +0000 (15:28 +0300)
committerIngo Molnar <mingo@kernel.org>
Wed, 9 Apr 2025 20:02:30 +0000 (22:02 +0200)
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.

Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: David Woodhouse <dwmw@amazon.co.uk>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Len Brown <len.brown@intel.com>
Link: https://lore.kernel.org/r/20250409122815.420041-1-rppt@kernel.org
arch/x86/include/asm/page_32_types.h
arch/x86/mm/Makefile
arch/x86/mm/init_32.c
arch/x86/mm/init_64.c
arch/x86/mm/mm_internal.h
arch/x86/mm/numa.c
arch/x86/mm/numa_32.c [deleted file]
arch/x86/mm/numa_64.c [deleted file]
arch/x86/mm/numa_internal.h [deleted file]

index a9b62e0e6f7960cdc3a146612649d528f37a0cb2..623f1e9f493edeec9fb2b402ac0552ed2565de9c 100644 (file)
@@ -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__ */
 
index 32035d5be5a017a97fb2699d647c4c70029a0591..1e72f06b6ba58eee1ce7a4df8583a7806c9b2018 100644 (file)
@@ -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
 
index ad662cc4605c69a479865654a4ceee6d0f1d0eed..d467f89191cd05b951b3ad0553b2e97b78458cfc 100644 (file)
@@ -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);
index 7c4f6f591f2b244dbc1173822b7230e2024cab23..b7655396f4e02db9217c4ba8cd697b228b4f279e 100644 (file)
@@ -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();
index 3f37b5c80bb32ff34656a20789449da92e853eb6..097aadc250f7442986cde998b17bab5bada85e3e 100644 (file)
@@ -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 */
index 64e5cdb2460ac24c37df5af46a4dd3cdc0bf6975..4bf04be29355ff2b7bfce534d619b6e86c1eafb1 100644 (file)
@@ -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;
 
diff --git a/arch/x86/mm/numa_32.c b/arch/x86/mm/numa_32.c
deleted file mode 100644 (file)
index 65fda40..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Written by: Patricia Gaughen <gone@us.ibm.com>, IBM Corporation
- * August 2002: added remote node KVA remap - Martin J. Bligh 
- *
- * Copyright (C) 2002, IBM Corp.
- *
- * All rights reserved.          
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/memblock.h>
-#include <linux/init.h>
-#include <linux/vmalloc.h>
-#include <asm/pgtable_areas.h>
-
-#include "numa_internal.h"
-
-extern unsigned long highend_pfn, highstart_pfn;
-
-void __init initmem_init(void)
-{
-       x86_numa_init();
-
-#ifdef CONFIG_HIGHMEM
-       highstart_pfn = highend_pfn = max_pfn;
-       if (max_pfn > max_low_pfn)
-               highstart_pfn = max_low_pfn;
-       printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
-              pages_to_mb(highend_pfn - highstart_pfn));
-       high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
-#else
-       high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
-#endif
-       printk(KERN_NOTICE "%ldMB LOWMEM available.\n",
-                       pages_to_mb(max_low_pfn));
-       printk(KERN_DEBUG "max_low_pfn = %lx, highstart_pfn = %lx\n",
-                       max_low_pfn, highstart_pfn);
-
-       printk(KERN_DEBUG "Low memory ends at vaddr %08lx\n",
-                       (ulong) pfn_to_kaddr(max_low_pfn));
-
-       printk(KERN_DEBUG "High memory starts at vaddr %08lx\n",
-                       (ulong) pfn_to_kaddr(highstart_pfn));
-
-       __vmalloc_start_set = true;
-       setup_bootmem_allocator();
-}
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c
deleted file mode 100644 (file)
index 59d8016..0000000
+++ /dev/null
@@ -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();
-}
diff --git a/arch/x86/mm/numa_internal.h b/arch/x86/mm/numa_internal.h
deleted file mode 100644 (file)
index 11e1ff3..0000000
+++ /dev/null
@@ -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 */