Skip to content

Commit

Permalink
arch, mm: move definition of node_data to generic code
Browse files Browse the repository at this point in the history
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/[email protected]
Signed-off-by: Mike Rapoport (Microsoft) <[email protected]>
Acked-by: David Hildenbrand <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Acked-by: Davidlohr Bueso <[email protected]>
Tested-by: Zi Yan <[email protected]> # for x86_64 and arm64
Tested-by: Jonathan Cameron <[email protected]> [arm64 + CXL via QEMU]
Acked-by: Dan Williams <[email protected]>
Cc: Alexander Gordeev <[email protected]>
Cc: Andreas Larsson <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Christophe Leroy <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: David S. Miller <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Huacai Chen <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiaxun Yang <[email protected]>
Cc: John Paul Adrian Glaubitz <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Palmer Dabbelt <[email protected]>
Cc: Rafael J. Wysocki <[email protected]>
Cc: Rob Herring (Arm) <[email protected]>
Cc: Samuel Holland <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Vasily Gorbik <[email protected]>
Cc: Will Deacon <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
rppt authored and akpm00 committed Sep 4, 2024
1 parent 3ac9999 commit 46bcce5
Show file tree
Hide file tree
Showing 32 changed files with 22 additions and 144 deletions.
1 change: 1 addition & 0 deletions arch/arm64/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ syscall-y += unistd_compat_32.h

generic-y += early_ioremap.h
generic-y += mcs_spinlock.h
generic-y += mmzone.h
generic-y += qrwlock.h
generic-y += qspinlock.h
generic-y += parport.h
Expand Down
13 changes: 0 additions & 13 deletions arch/arm64/include/asm/mmzone.h

This file was deleted.

1 change: 1 addition & 0 deletions arch/arm64/include/asm/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <linux/cpumask.h>

#ifdef CONFIG_NUMA
#include <asm/numa.h>

struct pci_bus;
int pcibus_to_node(struct pci_bus *bus);
Expand Down
1 change: 1 addition & 0 deletions arch/loongarch/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ generic-y += qrwlock.h
generic-y += qspinlock.h
generic-y += user.h
generic-y += ioctl.h
generic-y += mmzone.h
generic-y += statfs.h
generic-y += param.h
16 changes: 0 additions & 16 deletions arch/loongarch/include/asm/mmzone.h

This file was deleted.

1 change: 1 addition & 0 deletions arch/loongarch/include/asm/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <linux/smp.h>

#ifdef CONFIG_NUMA
#include <asm/numa.h>

extern cpumask_t cpus_on_node[];

Expand Down
3 changes: 0 additions & 3 deletions arch/loongarch/kernel/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@
#include <asm/time.h>

int numa_off;
struct pglist_data *node_data[MAX_NUMNODES];
unsigned char node_distances[MAX_NUMNODES][MAX_NUMNODES];

EXPORT_SYMBOL(node_data);
EXPORT_SYMBOL(node_distances);

static struct numa_meminfo numa_meminfo;
Expand Down
4 changes: 0 additions & 4 deletions arch/mips/include/asm/mach-ip27/mmzone.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,4 @@ extern struct node_data *__node_data[];

#define hub_data(n) (&__node_data[(n)]->hub)

extern struct pglist_data *node_data[];

#define NODE_DATA(nid) (node_data[nid])

#endif /* _ASM_MACH_MMZONE_H */
4 changes: 0 additions & 4 deletions arch/mips/include/asm/mach-loongson64/mmzone.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
#define pa_to_nid(addr) (((addr) & 0xf00000000000) >> NODE_ADDRSPACE_SHIFT)
#define nid_to_addrbase(nid) ((unsigned long)(nid) << NODE_ADDRSPACE_SHIFT)

extern struct pglist_data *node_data[];

#define NODE_DATA(n) (node_data[n])

extern void __init prom_init_numa_memory(void);

#endif /* _ASM_MACH_MMZONE_H */
2 changes: 0 additions & 2 deletions arch/mips/loongson64/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

unsigned char __node_distances[MAX_NUMNODES][MAX_NUMNODES];
EXPORT_SYMBOL(__node_distances);
struct pglist_data *node_data[MAX_NUMNODES];
EXPORT_SYMBOL(node_data);

cpumask_t __node_cpumask[MAX_NUMNODES];
EXPORT_SYMBOL(__node_cpumask);
Expand Down
3 changes: 0 additions & 3 deletions arch/mips/sgi-ip27/ip27-memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
#define SLOT_PFNSHIFT (SLOT_SHIFT - PAGE_SHIFT)
#define PFN_NASIDSHFT (NASID_SHFT - PAGE_SHIFT)

struct pglist_data *node_data[MAX_NUMNODES];
EXPORT_SYMBOL(node_data);

struct node_data *__node_data[MAX_NUMNODES];
EXPORT_SYMBOL(__node_data);

Expand Down
6 changes: 0 additions & 6 deletions arch/powerpc/include/asm/mmzone.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@

#ifdef CONFIG_NUMA

extern struct pglist_data *node_data[];
/*
* Return a pointer to the node data for node n.
*/
#define NODE_DATA(nid) (node_data[nid])

/*
* Following are specific to this numa platform.
*/
Expand Down
2 changes: 0 additions & 2 deletions arch/powerpc/mm/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ static char *cmdline __initdata;

int numa_cpu_lookup_table[NR_CPUS];
cpumask_var_t node_to_cpumask_map[MAX_NUMNODES];
struct pglist_data *node_data[MAX_NUMNODES];

EXPORT_SYMBOL(numa_cpu_lookup_table);
EXPORT_SYMBOL(node_to_cpumask_map);
EXPORT_SYMBOL(node_data);

static int primary_domain_index;
static int n_mem_addr_cells, n_mem_size_cells;
Expand Down
1 change: 1 addition & 0 deletions arch/riscv/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ syscall-y += syscall_table_64.h
generic-y += early_ioremap.h
generic-y += flat.h
generic-y += kvm_para.h
generic-y += mmzone.h
generic-y += parport.h
generic-y += spinlock.h
generic-y += spinlock_types.h
Expand Down
13 changes: 0 additions & 13 deletions arch/riscv/include/asm/mmzone.h

This file was deleted.

4 changes: 4 additions & 0 deletions arch/riscv/include/asm/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

#include <linux/arch_topology.h>

#ifdef CONFIG_NUMA
#include <asm/numa.h>
#endif

/* Replace task scheduler's default frequency-invariant accounting */
#define arch_scale_freq_tick topology_scale_freq_tick
#define arch_set_freq_scale topology_set_freq_scale
Expand Down
1 change: 1 addition & 0 deletions arch/s390/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ generated-y += unistd_nr.h
generic-y += asm-offsets.h
generic-y += kvm_types.h
generic-y += mcs_spinlock.h
generic-y += mmzone.h
17 changes: 0 additions & 17 deletions arch/s390/include/asm/mmzone.h

This file was deleted.

3 changes: 0 additions & 3 deletions arch/s390/kernel/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
#include <linux/node.h>
#include <asm/numa.h>

struct pglist_data *node_data[MAX_NUMNODES];
EXPORT_SYMBOL(node_data);

void __init numa_setup(void)
{
int nid;
Expand Down
3 changes: 0 additions & 3 deletions arch/sh/include/asm/mmzone.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
#ifdef CONFIG_NUMA
#include <linux/numa.h>

extern struct pglist_data *node_data[];
#define NODE_DATA(nid) (node_data[nid])

static inline int pfn_to_nid(unsigned long pfn)
{
int nid;
Expand Down
3 changes: 0 additions & 3 deletions arch/sh/mm/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
#include <linux/pfn.h>
#include <asm/sections.h>

struct pglist_data *node_data[MAX_NUMNODES] __read_mostly;
EXPORT_SYMBOL_GPL(node_data);

/*
* On SH machines the conventional approach is to stash system RAM
* in node 0, and other memory blocks in to node 1 and up, ordered by
Expand Down
4 changes: 0 additions & 4 deletions arch/sparc/include/asm/mmzone.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@

#include <linux/cpumask.h>

extern struct pglist_data *node_data[];

#define NODE_DATA(nid) (node_data[nid])

extern int numa_cpu_lookup_table[];
extern cpumask_t numa_cpumask_lookup_table[];

Expand Down
2 changes: 0 additions & 2 deletions arch/sparc/mm/init_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,11 +1115,9 @@ static void init_node_masks_nonnuma(void)
}

#ifdef CONFIG_NUMA
struct pglist_data *node_data[MAX_NUMNODES];

EXPORT_SYMBOL(numa_cpu_lookup_table);
EXPORT_SYMBOL(numa_cpumask_lookup_table);
EXPORT_SYMBOL(node_data);

static int scan_pio_for_cfg_handle(struct mdesc_handle *md, u64 pio,
u32 cfg_handle)
Expand Down
1 change: 1 addition & 0 deletions arch/x86/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ generated-y += xen-hypercalls.h

generic-y += early_ioremap.h
generic-y += mcs_spinlock.h
generic-y += mmzone.h
6 changes: 0 additions & 6 deletions arch/x86/include/asm/mmzone.h

This file was deleted.

17 changes: 0 additions & 17 deletions arch/x86/include/asm/mmzone_32.h

This file was deleted.

18 changes: 0 additions & 18 deletions arch/x86/include/asm/mmzone_64.h

This file was deleted.

3 changes: 0 additions & 3 deletions arch/x86/mm/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
int numa_off;
nodemask_t numa_nodes_parsed __initdata;

struct pglist_data *node_data[MAX_NUMNODES] __read_mostly;
EXPORT_SYMBOL(node_data);

static struct numa_meminfo numa_meminfo __initdata_or_meminfo;
static struct numa_meminfo numa_reserved_meminfo __initdata_or_meminfo;

Expand Down
2 changes: 0 additions & 2 deletions drivers/base/arch_numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

#include <asm/sections.h>

struct pglist_data *node_data[MAX_NUMNODES] __read_mostly;
EXPORT_SYMBOL(node_data);
nodemask_t numa_nodes_parsed __initdata;
static int cpu_to_node_map[NR_CPUS] = { [0 ... NR_CPUS-1] = NUMA_NO_NODE };

Expand Down
5 changes: 5 additions & 0 deletions include/asm-generic/mmzone.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_GENERIC_MMZONE_H
#define _ASM_GENERIC_MMZONE_H

#endif
3 changes: 3 additions & 0 deletions include/linux/numa.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ static inline bool numa_valid_node(int nid)
#ifdef CONFIG_NUMA
#include <asm/sparsemem.h>

extern struct pglist_data *node_data[];
#define NODE_DATA(nid) (node_data[nid])

/* Generic implementation available */
int numa_nearest_node(int node, unsigned int state);

Expand Down
3 changes: 3 additions & 0 deletions mm/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include <linux/printk.h>
#include <linux/numa.h>

struct pglist_data *node_data[MAX_NUMNODES];
EXPORT_SYMBOL(node_data);

/* Stub functions: */

#ifndef memory_add_physaddr_to_nid
Expand Down

0 comments on commit 46bcce5

Please sign in to comment.