Unverified Commit 4f0e8eef authored by Atish Patra's avatar Atish Patra Committed by Palmer Dabbelt
Browse files

riscv: Add numa support for riscv64 platform

Use the generic numa implementation to add NUMA support for RISC-V.
This is based on Greentime's patch[1] but modified to use generic NUMA
implementation and few more fixes.

[1] https://lkml.org/lkml/2020/1/10/233



Co-developed-by: default avatarGreentime Hu <greentime.hu@sifive.com>
Signed-off-by: default avatarGreentime Hu <greentime.hu@sifive.com>
Signed-off-by: default avatarAtish Patra <atish.patra@wdc.com>
Reviewed-by: default avatarAnup Patel <anup@brainfault.org>
Reviewed-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
parent 3e5b0bdb
Loading
Loading
Loading
Loading
+30 −1
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ config PAGE_OFFSET
	default 0xffffffe000000000 if 64BIT && MAXPHYSMEM_128GB

config ARCH_FLATMEM_ENABLE
	def_bool y
	def_bool !NUMA

config ARCH_SPARSEMEM_ENABLE
	def_bool y
@@ -298,6 +298,35 @@ config TUNE_GENERIC

endchoice

# Common NUMA Features
config NUMA
	bool "NUMA Memory Allocation and Scheduler Support"
	select GENERIC_ARCH_NUMA
	select OF_NUMA
	select ARCH_SUPPORTS_NUMA_BALANCING
	help
	  Enable NUMA (Non-Uniform Memory Access) support.

	  The kernel will try to allocate memory used by a CPU on the
	  local memory of the CPU and add some more NUMA awareness to the kernel.

config NODES_SHIFT
	int "Maximum NUMA Nodes (as a power of 2)"
	range 1 10
	default "2"
	depends on NEED_MULTIPLE_NODES
	help
	  Specify the maximum number of NUMA Nodes available on the target
	  system.  Increases memory reserved to accommodate various tables.

config USE_PERCPU_NUMA_NODE_ID
	def_bool y
	depends on NUMA

config NEED_PER_CPU_EMBED_FIRST_CHUNK
	def_bool y
	depends on NUMA

config RISCV_ISA_C
	bool "Emit compressed instructions when building Linux"
	default y
+13 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __ASM_MMZONE_H
#define __ASM_MMZONE_H

#ifdef CONFIG_NUMA

#include <asm/numa.h>

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

#endif /* CONFIG_NUMA */
#endif /* __ASM_MMZONE_H */
+8 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __ASM_NUMA_H
#define __ASM_NUMA_H

#include <asm/topology.h>
#include <asm-generic/numa.h>

#endif	/* __ASM_NUMA_H */
+14 −0
Original line number Diff line number Diff line
@@ -32,6 +32,20 @@ static inline int pci_proc_domain(struct pci_bus *bus)
	/* always show the domain in /proc */
	return 1;
}

#ifdef	CONFIG_NUMA

static inline int pcibus_to_node(struct pci_bus *bus)
{
	return dev_to_node(&bus->dev);
}
#ifndef cpumask_of_pcibus
#define cpumask_of_pcibus(bus)	(pcibus_to_node(bus) == -1 ?		\
				 cpu_all_mask :				\
				 cpumask_of_node(pcibus_to_node(bus)))
#endif
#endif	/* CONFIG_NUMA */

#endif  /* CONFIG_PCI */

#endif  /* _ASM_RISCV_PCI_H */
+8 −2
Original line number Diff line number Diff line
@@ -273,13 +273,19 @@ void __init setup_arch(char **cmdline_p)

static int __init topology_init(void)
{
	int i;
	int i, ret;

	for_each_online_node(i)
		register_one_node(i);

	for_each_possible_cpu(i) {
		struct cpu *cpu = &per_cpu(cpu_devices, i);

		cpu->hotpluggable = cpu_has_hotplug(i);
		register_cpu(cpu, i);
		ret = register_cpu(cpu, i);
		if (unlikely(ret))
			pr_warn("Warning: %s: register_cpu %d failed (%d)\n",
			       __func__, i, ret);
	}

	return 0;
Loading