Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arch, mm: move definition of node_data to generic code

Every architecture that supports NUMA defines node_data in the same way:

struct pglist_data *node_data[MAX_NUMNODES];

No reason to keep multiple copies of this definition and its forward
declarations, especially when such forward declaration is the only thing
in include/asm/mmzone.h for many architectures.

Add definition and declaration of node_data to generic code and drop
architecture-specific versions.

Link: https://lkml.kernel.org/r/20240807064110.1003856-8-rppt@kernel.org
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Davidlohr Bueso <dave@stgolabs.net>
Tested-by: Zi Yan <ziy@nvidia.com> # for x86_64 and arm64
Tested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> [arm64 + CXL via QEMU]
Acked-by: Dan Williams <dan.j.williams@intel.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Cc: Rob Herring (Arm) <robh@kernel.org>
Cc: Samuel Holland <samuel.holland@sifive.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Mike Rapoport (Microsoft) and committed by
Andrew Morton
46bcce50 3ac9999c

+22 -144
+1
arch/arm64/include/asm/Kbuild
··· 9 9 10 10 generic-y += early_ioremap.h 11 11 generic-y += mcs_spinlock.h 12 + generic-y += mmzone.h 12 13 generic-y += qrwlock.h 13 14 generic-y += qspinlock.h 14 15 generic-y += parport.h
-13
arch/arm64/include/asm/mmzone.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef __ASM_MMZONE_H 3 - #define __ASM_MMZONE_H 4 - 5 - #ifdef CONFIG_NUMA 6 - 7 - #include <asm/numa.h> 8 - 9 - extern struct pglist_data *node_data[]; 10 - #define NODE_DATA(nid) (node_data[(nid)]) 11 - 12 - #endif /* CONFIG_NUMA */ 13 - #endif /* __ASM_MMZONE_H */
+1
arch/arm64/include/asm/topology.h
··· 5 5 #include <linux/cpumask.h> 6 6 7 7 #ifdef CONFIG_NUMA 8 + #include <asm/numa.h> 8 9 9 10 struct pci_bus; 10 11 int pcibus_to_node(struct pci_bus *bus);
+1
arch/loongarch/include/asm/Kbuild
··· 9 9 generic-y += qspinlock.h 10 10 generic-y += user.h 11 11 generic-y += ioctl.h 12 + generic-y += mmzone.h 12 13 generic-y += statfs.h 13 14 generic-y += param.h
-16
arch/loongarch/include/asm/mmzone.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * Author: Huacai Chen (chenhuacai@loongson.cn) 4 - * Copyright (C) 2020-2022 Loongson Technology Corporation Limited 5 - */ 6 - #ifndef _ASM_MMZONE_H_ 7 - #define _ASM_MMZONE_H_ 8 - 9 - #include <asm/page.h> 10 - #include <asm/numa.h> 11 - 12 - extern struct pglist_data *node_data[]; 13 - 14 - #define NODE_DATA(nid) (node_data[(nid)]) 15 - 16 - #endif /* _ASM_MMZONE_H_ */
+1
arch/loongarch/include/asm/topology.h
··· 8 8 #include <linux/smp.h> 9 9 10 10 #ifdef CONFIG_NUMA 11 + #include <asm/numa.h> 11 12 12 13 extern cpumask_t cpus_on_node[]; 13 14
-3
arch/loongarch/kernel/numa.c
··· 27 27 #include <asm/time.h> 28 28 29 29 int numa_off; 30 - struct pglist_data *node_data[MAX_NUMNODES]; 31 30 unsigned char node_distances[MAX_NUMNODES][MAX_NUMNODES]; 32 - 33 - EXPORT_SYMBOL(node_data); 34 31 EXPORT_SYMBOL(node_distances); 35 32 36 33 static struct numa_meminfo numa_meminfo;
-4
arch/mips/include/asm/mach-ip27/mmzone.h
··· 24 24 25 25 #define hub_data(n) (&__node_data[(n)]->hub) 26 26 27 - extern struct pglist_data *node_data[]; 28 - 29 - #define NODE_DATA(nid) (node_data[nid]) 30 - 31 27 #endif /* _ASM_MACH_MMZONE_H */
-4
arch/mips/include/asm/mach-loongson64/mmzone.h
··· 14 14 #define pa_to_nid(addr) (((addr) & 0xf00000000000) >> NODE_ADDRSPACE_SHIFT) 15 15 #define nid_to_addrbase(nid) ((unsigned long)(nid) << NODE_ADDRSPACE_SHIFT) 16 16 17 - extern struct pglist_data *node_data[]; 18 - 19 - #define NODE_DATA(n) (node_data[n]) 20 - 21 17 extern void __init prom_init_numa_memory(void); 22 18 23 19 #endif /* _ASM_MACH_MMZONE_H */
-2
arch/mips/loongson64/numa.c
··· 29 29 30 30 unsigned char __node_distances[MAX_NUMNODES][MAX_NUMNODES]; 31 31 EXPORT_SYMBOL(__node_distances); 32 - struct pglist_data *node_data[MAX_NUMNODES]; 33 - EXPORT_SYMBOL(node_data); 34 32 35 33 cpumask_t __node_cpumask[MAX_NUMNODES]; 36 34 EXPORT_SYMBOL(__node_cpumask);
-3
arch/mips/sgi-ip27/ip27-memory.c
··· 34 34 #define SLOT_PFNSHIFT (SLOT_SHIFT - PAGE_SHIFT) 35 35 #define PFN_NASIDSHFT (NASID_SHFT - PAGE_SHIFT) 36 36 37 - struct pglist_data *node_data[MAX_NUMNODES]; 38 - EXPORT_SYMBOL(node_data); 39 - 40 37 struct node_data *__node_data[MAX_NUMNODES]; 41 38 EXPORT_SYMBOL(__node_data); 42 39
-6
arch/powerpc/include/asm/mmzone.h
··· 20 20 21 21 #ifdef CONFIG_NUMA 22 22 23 - extern struct pglist_data *node_data[]; 24 - /* 25 - * Return a pointer to the node data for node n. 26 - */ 27 - #define NODE_DATA(nid) (node_data[nid]) 28 - 29 23 /* 30 24 * Following are specific to this numa platform. 31 25 */
-2
arch/powerpc/mm/numa.c
··· 43 43 44 44 int numa_cpu_lookup_table[NR_CPUS]; 45 45 cpumask_var_t node_to_cpumask_map[MAX_NUMNODES]; 46 - struct pglist_data *node_data[MAX_NUMNODES]; 47 46 48 47 EXPORT_SYMBOL(numa_cpu_lookup_table); 49 48 EXPORT_SYMBOL(node_to_cpumask_map); 50 - EXPORT_SYMBOL(node_data); 51 49 52 50 static int primary_domain_index; 53 51 static int n_mem_addr_cells, n_mem_size_cells;
+1
arch/riscv/include/asm/Kbuild
··· 5 5 generic-y += early_ioremap.h 6 6 generic-y += flat.h 7 7 generic-y += kvm_para.h 8 + generic-y += mmzone.h 8 9 generic-y += parport.h 9 10 generic-y += spinlock.h 10 11 generic-y += spinlock_types.h
-13
arch/riscv/include/asm/mmzone.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef __ASM_MMZONE_H 3 - #define __ASM_MMZONE_H 4 - 5 - #ifdef CONFIG_NUMA 6 - 7 - #include <asm/numa.h> 8 - 9 - extern struct pglist_data *node_data[]; 10 - #define NODE_DATA(nid) (node_data[(nid)]) 11 - 12 - #endif /* CONFIG_NUMA */ 13 - #endif /* __ASM_MMZONE_H */
+4
arch/riscv/include/asm/topology.h
··· 4 4 5 5 #include <linux/arch_topology.h> 6 6 7 + #ifdef CONFIG_NUMA 8 + #include <asm/numa.h> 9 + #endif 10 + 7 11 /* Replace task scheduler's default frequency-invariant accounting */ 8 12 #define arch_scale_freq_tick topology_scale_freq_tick 9 13 #define arch_set_freq_scale topology_set_freq_scale
+1
arch/s390/include/asm/Kbuild
··· 7 7 generic-y += asm-offsets.h 8 8 generic-y += kvm_types.h 9 9 generic-y += mcs_spinlock.h 10 + generic-y += mmzone.h
-17
arch/s390/include/asm/mmzone.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * NUMA support for s390 4 - * 5 - * Copyright IBM Corp. 2015 6 - */ 7 - 8 - #ifndef _ASM_S390_MMZONE_H 9 - #define _ASM_S390_MMZONE_H 10 - 11 - #ifdef CONFIG_NUMA 12 - 13 - extern struct pglist_data *node_data[]; 14 - #define NODE_DATA(nid) (node_data[nid]) 15 - 16 - #endif /* CONFIG_NUMA */ 17 - #endif /* _ASM_S390_MMZONE_H */
-3
arch/s390/kernel/numa.c
··· 14 14 #include <linux/node.h> 15 15 #include <asm/numa.h> 16 16 17 - struct pglist_data *node_data[MAX_NUMNODES]; 18 - EXPORT_SYMBOL(node_data); 19 - 20 17 void __init numa_setup(void) 21 18 { 22 19 int nid;
-3
arch/sh/include/asm/mmzone.h
··· 5 5 #ifdef CONFIG_NUMA 6 6 #include <linux/numa.h> 7 7 8 - extern struct pglist_data *node_data[]; 9 - #define NODE_DATA(nid) (node_data[nid]) 10 - 11 8 static inline int pfn_to_nid(unsigned long pfn) 12 9 { 13 10 int nid;
-3
arch/sh/mm/numa.c
··· 14 14 #include <linux/pfn.h> 15 15 #include <asm/sections.h> 16 16 17 - struct pglist_data *node_data[MAX_NUMNODES] __read_mostly; 18 - EXPORT_SYMBOL_GPL(node_data); 19 - 20 17 /* 21 18 * On SH machines the conventional approach is to stash system RAM 22 19 * in node 0, and other memory blocks in to node 1 and up, ordered by
-4
arch/sparc/include/asm/mmzone.h
··· 6 6 7 7 #include <linux/cpumask.h> 8 8 9 - extern struct pglist_data *node_data[]; 10 - 11 - #define NODE_DATA(nid) (node_data[nid]) 12 - 13 9 extern int numa_cpu_lookup_table[]; 14 10 extern cpumask_t numa_cpumask_lookup_table[]; 15 11
-2
arch/sparc/mm/init_64.c
··· 1115 1115 } 1116 1116 1117 1117 #ifdef CONFIG_NUMA 1118 - struct pglist_data *node_data[MAX_NUMNODES]; 1119 1118 1120 1119 EXPORT_SYMBOL(numa_cpu_lookup_table); 1121 1120 EXPORT_SYMBOL(numa_cpumask_lookup_table); 1122 - EXPORT_SYMBOL(node_data); 1123 1121 1124 1122 static int scan_pio_for_cfg_handle(struct mdesc_handle *md, u64 pio, 1125 1123 u32 cfg_handle)
+1
arch/x86/include/asm/Kbuild
··· 11 11 12 12 generic-y += early_ioremap.h 13 13 generic-y += mcs_spinlock.h 14 + generic-y += mmzone.h
-6
arch/x86/include/asm/mmzone.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifdef CONFIG_X86_32 3 - # include <asm/mmzone_32.h> 4 - #else 5 - # include <asm/mmzone_64.h> 6 - #endif
-17
arch/x86/include/asm/mmzone_32.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * Written by Pat Gaughen (gone@us.ibm.com) Mar 2002 4 - * 5 - */ 6 - 7 - #ifndef _ASM_X86_MMZONE_32_H 8 - #define _ASM_X86_MMZONE_32_H 9 - 10 - #include <asm/smp.h> 11 - 12 - #ifdef CONFIG_NUMA 13 - extern struct pglist_data *node_data[]; 14 - #define NODE_DATA(nid) (node_data[nid]) 15 - #endif /* CONFIG_NUMA */ 16 - 17 - #endif /* _ASM_X86_MMZONE_32_H */
-18
arch/x86/include/asm/mmzone_64.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* K8 NUMA support */ 3 - /* Copyright 2002,2003 by Andi Kleen, SuSE Labs */ 4 - /* 2.5 Version loosely based on the NUMAQ Code by Pat Gaughen. */ 5 - #ifndef _ASM_X86_MMZONE_64_H 6 - #define _ASM_X86_MMZONE_64_H 7 - 8 - #ifdef CONFIG_NUMA 9 - 10 - #include <linux/mmdebug.h> 11 - #include <asm/smp.h> 12 - 13 - extern struct pglist_data *node_data[]; 14 - 15 - #define NODE_DATA(nid) (node_data[nid]) 16 - 17 - #endif 18 - #endif /* _ASM_X86_MMZONE_64_H */
-3
arch/x86/mm/numa.c
··· 24 24 int numa_off; 25 25 nodemask_t numa_nodes_parsed __initdata; 26 26 27 - struct pglist_data *node_data[MAX_NUMNODES] __read_mostly; 28 - EXPORT_SYMBOL(node_data); 29 - 30 27 static struct numa_meminfo numa_meminfo __initdata_or_meminfo; 31 28 static struct numa_meminfo numa_reserved_meminfo __initdata_or_meminfo; 32 29
-2
drivers/base/arch_numa.c
··· 15 15 16 16 #include <asm/sections.h> 17 17 18 - struct pglist_data *node_data[MAX_NUMNODES] __read_mostly; 19 - EXPORT_SYMBOL(node_data); 20 18 nodemask_t numa_nodes_parsed __initdata; 21 19 static int cpu_to_node_map[NR_CPUS] = { [0 ... NR_CPUS-1] = NUMA_NO_NODE }; 22 20
+5
include/asm-generic/mmzone.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _ASM_GENERIC_MMZONE_H 3 + #define _ASM_GENERIC_MMZONE_H 4 + 5 + #endif
+3
include/linux/numa.h
··· 30 30 #ifdef CONFIG_NUMA 31 31 #include <asm/sparsemem.h> 32 32 33 + extern struct pglist_data *node_data[]; 34 + #define NODE_DATA(nid) (node_data[nid]) 35 + 33 36 /* Generic implementation available */ 34 37 int numa_nearest_node(int node, unsigned int state); 35 38
+3
mm/numa.c
··· 3 3 #include <linux/printk.h> 4 4 #include <linux/numa.h> 5 5 6 + struct pglist_data *node_data[MAX_NUMNODES]; 7 + EXPORT_SYMBOL(node_data); 8 + 6 9 /* Stub functions: */ 7 10 8 11 #ifndef memory_add_physaddr_to_nid