Commit c29a7baf authored by Michael Holzheu's avatar Michael Holzheu Committed by Martin Schwidefsky

s390/numa: add emulation support

NUMA emulation (aka fake NUMA) distributes the available memory to nodes
without using real topology information about the physical memory of the
machine.

Splitting the system memory into nodes replicates the memory management
structures for each node. Particularly each node has its own "mm locks"
and its own "kswapd" task.

For large systems, under certain conditions, this results in improved
system performance and/or latency based on reduced pressure on the mm
locks and the kswapd tasks.

NUMA emulation distributes CPUs to nodes while respecting the original
machine topology information. This is done by trying to avoid to separate
CPUs which reside on the same book or even on the same MC. Because the
current Linux scheduler code requires a stable cpu to node mapping, cores
are pinned to nodes when the first CPU thread is set online.

This patch is based on the initial implementation from Philipp Hachtmann.
Signed-off-by: default avatarMichael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent e8054b65
...@@ -423,6 +423,43 @@ config NODES_SHIFT ...@@ -423,6 +423,43 @@ config NODES_SHIFT
Specify the maximum number of NUMA nodes available on the target Specify the maximum number of NUMA nodes available on the target
system. Increases memory reserved to accommodate various tables. system. Increases memory reserved to accommodate various tables.
menu "Select NUMA modes"
depends on NUMA
config NUMA_EMU
bool "NUMA emulation"
default y
help
Numa emulation mode will split the available system memory into
equal chunks which then are distributed over the configured number
of nodes in a round-robin manner.
The number of fake nodes is limited by the number of available memory
chunks (i.e. memory size / fake size) and the number of supported
nodes in the kernel.
The CPUs are assigned to the nodes in a way that partially respects
the original machine topology (if supported by the machine).
Fair distribution of the CPUs is not guaranteed.
config EMU_SIZE
hex "NUMA emulation memory chunk size"
default 0x10000000
range 0x400000 0x100000000
depends on NUMA_EMU
help
Select the default size by which the memory is chopped and then
assigned to emulated NUMA nodes.
This can be overridden by specifying
emu_size=<n>
on the kernel command line where also suffixes K, M, G, and T are
supported.
endmenu
config SCHED_MC config SCHED_MC
def_bool n def_bool n
......
...@@ -26,6 +26,10 @@ extern int numa_debug_enabled; ...@@ -26,6 +26,10 @@ extern int numa_debug_enabled;
static inline void numa_setup(void) { } static inline void numa_setup(void) { }
static inline void numa_update_cpu_topology(void) { } static inline void numa_update_cpu_topology(void) { }
static inline int numa_pfn_to_nid(unsigned long pfn)
{
return 0;
}
#endif /* CONFIG_NUMA */ #endif /* CONFIG_NUMA */
#endif /* _ASM_S390_NUMA_H */ #endif /* _ASM_S390_NUMA_H */
obj-y += numa.o obj-y += numa.o
obj-y += toptree.o obj-y += toptree.o
obj-$(CONFIG_NUMA_EMU) += mode_emu.o
This diff is collapsed.
...@@ -175,6 +175,10 @@ static int __init parse_numa(char *parm) ...@@ -175,6 +175,10 @@ static int __init parse_numa(char *parm)
{ {
if (strcmp(parm, numa_mode_plain.name) == 0) if (strcmp(parm, numa_mode_plain.name) == 0)
mode = &numa_mode_plain; mode = &numa_mode_plain;
#ifdef CONFIG_NUMA_EMU
if (strcmp(parm, numa_mode_emu.name) == 0)
mode = &numa_mode_emu;
#endif
return 0; return 0;
} }
early_param("numa", parse_numa); early_param("numa", parse_numa);
...@@ -19,5 +19,6 @@ struct numa_mode { ...@@ -19,5 +19,6 @@ struct numa_mode {
}; };
extern const struct numa_mode numa_mode_plain; extern const struct numa_mode numa_mode_plain;
extern const struct numa_mode numa_mode_emu;
#endif /* __S390_NUMA_MODE_H */ #endif /* __S390_NUMA_MODE_H */
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <asm/setup.h> #include <asm/setup.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/sclp.h> #include <asm/sclp.h>
#include <asm/numa.h>
#include "sclp.h" #include "sclp.h"
...@@ -388,11 +389,11 @@ static struct notifier_block sclp_mem_nb = { ...@@ -388,11 +389,11 @@ static struct notifier_block sclp_mem_nb = {
}; };
static void __init align_to_block_size(unsigned long long *start, static void __init align_to_block_size(unsigned long long *start,
unsigned long long *size) unsigned long long *size,
unsigned long long alignment)
{ {
unsigned long long start_align, size_align, alignment; unsigned long long start_align, size_align;
alignment = memory_block_size_bytes();
start_align = roundup(*start, alignment); start_align = roundup(*start, alignment);
size_align = rounddown(*start + *size, alignment) - start_align; size_align = rounddown(*start + *size, alignment) - start_align;
...@@ -404,8 +405,8 @@ static void __init align_to_block_size(unsigned long long *start, ...@@ -404,8 +405,8 @@ static void __init align_to_block_size(unsigned long long *start,
static void __init add_memory_merged(u16 rn) static void __init add_memory_merged(u16 rn)
{ {
unsigned long long start, size, addr, block_size;
static u16 first_rn, num; static u16 first_rn, num;
unsigned long long start, size;
if (rn && first_rn && (first_rn + num == rn)) { if (rn && first_rn && (first_rn + num == rn)) {
num++; num++;
...@@ -423,9 +424,12 @@ static void __init add_memory_merged(u16 rn) ...@@ -423,9 +424,12 @@ static void __init add_memory_merged(u16 rn)
goto skip_add; goto skip_add;
if (memory_end_set && (start + size > memory_end)) if (memory_end_set && (start + size > memory_end))
size = memory_end - start; size = memory_end - start;
align_to_block_size(&start, &size); block_size = memory_block_size_bytes();
if (size) align_to_block_size(&start, &size, block_size);
add_memory(0, start, size); if (!size)
goto skip_add;
for (addr = start; addr < start + size; addr += block_size)
add_memory(numa_pfn_to_nid(PFN_DOWN(addr)), addr, block_size);
skip_add: skip_add:
first_rn = rn; first_rn = rn;
num = 1; num = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment