Commit 701dc81e authored by Heiko Carstens's avatar Heiko Carstens Committed by Vasily Gorbik

s390/mm: remove fake numa support

It turned out that fake numa support is rather useless on s390, since
there are no scenarios where there is any performance or other benefit
when used.

However it does provide maintenance cost and breaks from time to time.
Therefore remove it.

CONFIG_NUMA is still supported with a very small backend and only one
node. This way userspace applications which require NUMA interfaces
continue to work.

Note that NODES_SHIFT is set to 1 (= 2 nodes) instead of 0 (= 1 node),
since there is quite a bit of kernel code which assumes that more than
one node is possible if CONFIG_NUMA is enabled.
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
parent 4a559cd1
......@@ -450,14 +450,6 @@ config NR_CPUS
config HOTPLUG_CPU
def_bool y
# Some NUMA nodes have memory ranges that span
# other nodes. Even though a pfn is valid and
# between a node's start and end pfns, it may not
# reside on that node. See memmap_init_zone()
# for details. <- They meant memory holes!
config NODES_SPAN_OTHER_NODES
def_bool NUMA
config NUMA
bool "NUMA support"
depends on SCHED_TOPOLOGY
......@@ -467,58 +459,9 @@ config NUMA
This option adds NUMA support to the kernel.
An operation mode can be selected by appending
numa=<method> to the kernel command line.
The default behaviour is identical to appending numa=plain to
the command line. This will create just one node with all
available memory and all CPUs in it.
config NODES_SHIFT
int "Maximum NUMA nodes (as a power of 2)"
range 1 10
depends on NUMA
default "4"
help
Specify the maximum number of NUMA nodes available on the target
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
int
default "1"
config SCHED_SMT
def_bool n
......
......@@ -13,24 +13,13 @@
#ifdef CONFIG_NUMA
#include <linux/numa.h>
#include <linux/cpumask.h>
void numa_setup(void);
int numa_pfn_to_nid(unsigned long pfn);
int __node_distance(int a, int b);
void numa_update_cpu_topology(void);
extern cpumask_t node_to_cpumask_map[MAX_NUMNODES];
extern int numa_debug_enabled;
#else
static inline void numa_setup(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 /* _ASM_S390_NUMA_H */
......@@ -16,7 +16,6 @@ struct cpu_topology_s390 {
unsigned short socket_id;
unsigned short book_id;
unsigned short drawer_id;
unsigned short node_id;
unsigned short dedicated : 1;
cpumask_t thread_mask;
cpumask_t core_mask;
......@@ -71,19 +70,23 @@ static inline void topology_expect_change(void) { }
#define cpu_to_node cpu_to_node
static inline int cpu_to_node(int cpu)
{
return cpu_topology[cpu].node_id;
return 0;
}
/* Returns a pointer to the cpumask of CPUs on node 'node'. */
#define cpumask_of_node cpumask_of_node
static inline const struct cpumask *cpumask_of_node(int node)
{
return &node_to_cpumask_map[node];
return cpu_possible_mask;
}
#define pcibus_to_node(bus) __pcibus_to_node(bus)
#define node_distance(a, b) __node_distance(a, b)
static inline int __node_distance(int a, int b)
{
return 0;
}
#else /* !CONFIG_NUMA */
......
......@@ -790,6 +790,7 @@ static void __init memblock_add_mem_detect_info(void)
memblock_physmem_add(start, end - start);
}
memblock_set_bottom_up(false);
memblock_set_node(0, ULONG_MAX, &memblock.memory, 0);
memblock_dump_all();
}
......
......@@ -26,7 +26,6 @@
#include <linux/nodemask.h>
#include <linux/node.h>
#include <asm/sysinfo.h>
#include <asm/numa.h>
#define PTF_HORIZONTAL (0UL)
#define PTF_VERTICAL (1UL)
......@@ -267,7 +266,6 @@ static void update_cpu_masks(void)
cpumask_set_cpu(cpu, &cpus_with_topology);
}
}
numa_update_cpu_topology();
}
void store_topology(struct sysinfo_15_1_x *info)
......
# SPDX-License-Identifier: GPL-2.0
obj-y += numa.o
obj-y += toptree.o
obj-$(CONFIG_NUMA_EMU) += mode_emu.o
This diff is collapsed.
......@@ -7,165 +7,36 @@
* Copyright IBM Corp. 2015
*/
#define KMSG_COMPONENT "numa"
#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
#include <linux/kernel.h>
#include <linux/mmzone.h>
#include <linux/cpumask.h>
#include <linux/memblock.h>
#include <linux/slab.h>
#include <linux/node.h>
#include <asm/numa.h>
#include "numa_mode.h"
pg_data_t *node_data[MAX_NUMNODES];
struct pglist_data *node_data[MAX_NUMNODES];
EXPORT_SYMBOL(node_data);
cpumask_t node_to_cpumask_map[MAX_NUMNODES];
EXPORT_SYMBOL(node_to_cpumask_map);
static void plain_setup(void)
{
node_set(0, node_possible_map);
}
const struct numa_mode numa_mode_plain = {
.name = "plain",
.setup = plain_setup,
};
static const struct numa_mode *mode = &numa_mode_plain;
int numa_pfn_to_nid(unsigned long pfn)
{
return mode->__pfn_to_nid ? mode->__pfn_to_nid(pfn) : 0;
}
void numa_update_cpu_topology(void)
{
if (mode->update_cpu_topology)
mode->update_cpu_topology();
}
int __node_distance(int a, int b)
{
return mode->distance ? mode->distance(a, b) : 0;
}
EXPORT_SYMBOL(__node_distance);
int numa_debug_enabled;
/*
* numa_setup_memory() - Assign bootmem to nodes
*
* The memory is first added to memblock without any respect to nodes.
* This is fixed before remaining memblock memory is handed over to the
* buddy allocator.
* An important side effect is that large bootmem allocations might easily
* cross node boundaries, which can be needed for large allocations with
* smaller memory stripes in each node (i.e. when using NUMA emulation).
*
* Memory defines nodes:
* Therefore this routine also sets the nodes online with memory.
*/
static void __init numa_setup_memory(void)
void __init numa_setup(void)
{
unsigned long cur_base, align, end_of_dram;
int nid = 0;
end_of_dram = memblock_end_of_DRAM();
align = mode->align ? mode->align() : ULONG_MAX;
/*
* Step through all available memory and assign it to the nodes
* indicated by the mode implementation.
* All nodes which are seen here will be set online.
*/
cur_base = 0;
do {
nid = numa_pfn_to_nid(PFN_DOWN(cur_base));
node_set_online(nid);
memblock_set_node(cur_base, align, &memblock.memory, nid);
cur_base += align;
} while (cur_base < end_of_dram);
int nid;
/* Allocate and fill out node_data */
nodes_clear(node_possible_map);
node_set(0, node_possible_map);
node_set_online(0);
for (nid = 0; nid < MAX_NUMNODES; nid++) {
NODE_DATA(nid) = memblock_alloc(sizeof(pg_data_t), 8);
if (!NODE_DATA(nid))
panic("%s: Failed to allocate %zu bytes align=0x%x\n",
__func__, sizeof(pg_data_t), 8);
}
for_each_online_node(nid) {
unsigned long start_pfn, end_pfn;
unsigned long t_start, t_end;
int i;
start_pfn = ULONG_MAX;
end_pfn = 0;
for_each_mem_pfn_range(i, nid, &t_start, &t_end, NULL) {
if (t_start < start_pfn)
start_pfn = t_start;
if (t_end > end_pfn)
end_pfn = t_end;
}
NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn;
NODE_DATA(nid)->node_id = nid;
}
}
/*
* numa_setup() - Earliest initialization
*
* Assign the mode and call the mode's setup routine.
*/
void __init numa_setup(void)
{
pr_info("NUMA mode: %s\n", mode->name);
nodes_clear(node_possible_map);
/* Initially attach all possible CPUs to node 0. */
cpumask_copy(&node_to_cpumask_map[0], cpu_possible_mask);
if (mode->setup)
mode->setup();
numa_setup_memory();
memblock_dump_all();
NODE_DATA(0)->node_spanned_pages = memblock_end_of_DRAM() >> PAGE_SHIFT;
NODE_DATA(0)->node_id = 0;
}
/*
* numa_init_late() - Initialization initcall
*
* Register NUMA nodes.
*/
static int __init numa_init_late(void)
{
int nid;
for_each_online_node(nid)
register_one_node(nid);
register_one_node(0);
return 0;
}
arch_initcall(numa_init_late);
static int __init parse_debug(char *parm)
{
numa_debug_enabled = 1;
return 0;
}
early_param("numa_debug", parse_debug);
static int __init parse_numa(char *parm)
{
if (!parm)
return 1;
if (strcmp(parm, numa_mode_plain.name) == 0)
mode = &numa_mode_plain;
#ifdef CONFIG_NUMA_EMU
if (strcmp(parm, numa_mode_emu.name) == 0)
mode = &numa_mode_emu;
#endif
return 0;
}
early_param("numa", parse_numa);
/* SPDX-License-Identifier: GPL-2.0 */
/*
* NUMA support for s390
*
* Define declarations used for communication between NUMA mode
* implementations and NUMA core functionality.
*
* Copyright IBM Corp. 2015
*/
#ifndef __S390_NUMA_MODE_H
#define __S390_NUMA_MODE_H
struct numa_mode {
char *name; /* Name of mode */
void (*setup)(void); /* Initizalize mode */
void (*update_cpu_topology)(void); /* Called by topology code */
int (*__pfn_to_nid)(unsigned long pfn); /* PFN to node ID */
unsigned long (*align)(void); /* Minimum node alignment */
int (*distance)(int a, int b); /* Distance between two nodes */
};
extern const struct numa_mode numa_mode_plain;
extern const struct numa_mode numa_mode_emu;
#endif /* __S390_NUMA_MODE_H */
// SPDX-License-Identifier: GPL-2.0
/*
* NUMA support for s390
*
* A tree structure used for machine topology mangling
*
* Copyright IBM Corp. 2015
*/
#include <linux/kernel.h>
#include <linux/memblock.h>
#include <linux/cpumask.h>
#include <linux/list.h>
#include <linux/list_sort.h>
#include <linux/slab.h>
#include <asm/numa.h>
#include "toptree.h"
/**
* toptree_alloc - Allocate and initialize a new tree node.
* @level: The node's vertical level; level 0 contains the leaves.
* @id: ID number, explicitly not unique beyond scope of node's siblings
*
* Allocate a new tree node and initialize it.
*
* RETURNS:
* Pointer to the new tree node or NULL on error
*/
struct toptree __ref *toptree_alloc(int level, int id)
{
struct toptree *res;
if (slab_is_available())
res = kzalloc(sizeof(*res), GFP_KERNEL);
else
res = memblock_alloc(sizeof(*res), 8);
if (!res)
return res;
INIT_LIST_HEAD(&res->children);
INIT_LIST_HEAD(&res->sibling);
cpumask_clear(&res->mask);
res->level = level;
res->id = id;
return res;
}
/**
* toptree_remove - Remove a tree node from a tree
* @cand: Pointer to the node to remove
*
* The node is detached from its parent node. The parent node's
* masks will be updated to reflect the loss of the child.
*/
static void toptree_remove(struct toptree *cand)
{
struct toptree *oldparent;
list_del_init(&cand->sibling);
oldparent = cand->parent;
cand->parent = NULL;
toptree_update_mask(oldparent);
}
/**
* toptree_free - discard a tree node
* @cand: Pointer to the tree node to discard
*
* Checks if @cand is attached to a parent node. Detaches it
* cleanly using toptree_remove. Possible children are freed
* recursively. In the end @cand itself is freed.
*/
void __ref toptree_free(struct toptree *cand)
{
struct toptree *child, *tmp;
if (cand->parent)
toptree_remove(cand);
toptree_for_each_child_safe(child, tmp, cand)
toptree_free(child);
if (slab_is_available())
kfree(cand);
else
memblock_free_early((unsigned long)cand, sizeof(*cand));
}
/**
* toptree_update_mask - Update node bitmasks
* @cand: Pointer to a tree node
*
* The node's cpumask will be updated by combining all children's
* masks. Then toptree_update_mask is called recursively for the
* parent if applicable.
*
* NOTE:
* This must not be called on leaves. If called on a leaf, its
* CPU mask is cleared and lost.
*/
void toptree_update_mask(struct toptree *cand)
{
struct toptree *child;
cpumask_clear(&cand->mask);
list_for_each_entry(child, &cand->children, sibling)
cpumask_or(&cand->mask, &cand->mask, &child->mask);
if (cand->parent)
toptree_update_mask(cand->parent);
}
/**
* toptree_insert - Insert a tree node into tree
* @cand: Pointer to the node to insert
* @target: Pointer to the node to which @cand will added as a child
*
* Insert a tree node into a tree. Masks will be updated automatically.
*
* RETURNS:
* 0 on success, -1 if NULL is passed as argument or the node levels
* don't fit.
*/
static int toptree_insert(struct toptree *cand, struct toptree *target)
{
if (!cand || !target)
return -1;
if (target->level != (cand->level + 1))
return -1;
list_add_tail(&cand->sibling, &target->children);
cand->parent = target;
toptree_update_mask(target);
return 0;
}
/**
* toptree_move_children - Move all child nodes of a node to a new place
* @cand: Pointer to the node whose children are to be moved
* @target: Pointer to the node to which @cand's children will be attached
*
* Take all child nodes of @cand and move them using toptree_move.
*/
static void toptree_move_children(struct toptree *cand, struct toptree *target)
{
struct toptree *child, *tmp;
toptree_for_each_child_safe(child, tmp, cand)
toptree_move(child, target);
}
/**
* toptree_unify - Merge children with same ID
* @cand: Pointer to node whose direct children should be made unique
*
* When mangling the tree it is possible that a node has two or more children
* which have the same ID. This routine merges these children into one and
* moves all children of the merged nodes into the unified node.
*/
void toptree_unify(struct toptree *cand)
{
struct toptree *child, *tmp, *cand_copy;
/* Threads cannot be split, cores are not split */
if (cand->level < 2)
return;
cand_copy = toptree_alloc(cand->level, 0);
toptree_for_each_child_safe(child, tmp, cand) {
struct toptree *tmpchild;
if (!cpumask_empty(&child->mask)) {
tmpchild = toptree_get_child(cand_copy, child->id);
toptree_move_children(child, tmpchild);
}
toptree_free(child);
}
toptree_move_children(cand_copy, cand);
toptree_free(cand_copy);
toptree_for_each_child(child, cand)
toptree_unify(child);
}
/**
* toptree_move - Move a node to another context
* @cand: Pointer to the node to move
* @target: Pointer to the node where @cand should go
*
* In the easiest case @cand is exactly on the level below @target
* and will be immediately moved to the target.
*
* If @target's level is not the direct parent level of @cand,
* nodes for the missing levels are created and put between
* @cand and @target. The "stacking" nodes' IDs are taken from
* @cand's parents.
*
* After this it is likely to have redundant nodes in the tree
* which are addressed by means of toptree_unify.
*/
void toptree_move(struct toptree *cand, struct toptree *target)
{
struct toptree *stack_target, *real_insert_point, *ptr, *tmp;
if (cand->level + 1 == target->level) {
toptree_remove(cand);
toptree_insert(cand, target);
return;
}
real_insert_point = NULL;
ptr = cand;
stack_target = NULL;
do {
tmp = stack_target;
stack_target = toptree_alloc(ptr->level + 1,
ptr->parent->id);
toptree_insert(tmp, stack_target);
if (!real_insert_point)
real_insert_point = stack_target;
ptr = ptr->parent;
} while (stack_target->level < (target->level - 1));
toptree_remove(cand);
toptree_insert(cand, real_insert_point);
toptree_insert(stack_target, target);
}
/**
* toptree_get_child - Access a tree node's child by its ID
* @cand: Pointer to tree node whose child is to access
* @id: The desired child's ID
*
* @cand's children are searched for a child with matching ID.
* If no match can be found, a new child with the desired ID
* is created and returned.
*/
struct toptree *toptree_get_child(struct toptree *cand, int id)
{
struct toptree *child;
toptree_for_each_child(child, cand)
if (child->id == id)
return child;
child = toptree_alloc(cand->level-1, id);
toptree_insert(child, cand);
return child;
}
/**
* toptree_first - Find the first descendant on specified level
* @context: Pointer to tree node whose descendants are to be used
* @level: The level of interest
*
* RETURNS:
* @context's first descendant on the specified level, or NULL
* if there is no matching descendant
*/
struct toptree *toptree_first(struct toptree *context, int level)
{
struct toptree *child, *tmp;
if (context->level == level)
return context;
if (!list_empty(&context->children)) {
list_for_each_entry(child, &context->children, sibling) {
tmp = toptree_first(child, level);
if (tmp)
return tmp;
}
}
return NULL;
}
/**
* toptree_next_sibling - Return next sibling
* @cur: Pointer to a tree node
*
* RETURNS:
* If @cur has a parent and is not the last in the parent's children list,
* the next sibling is returned. Or NULL when there are no siblings left.
*/
static struct toptree *toptree_next_sibling(struct toptree *cur)
{
if (cur->parent == NULL)
return NULL;
if (cur == list_last_entry(&cur->parent->children,
struct toptree, sibling))
return NULL;
return (struct toptree *) list_next_entry(cur, sibling);
}
/**
* toptree_next - Tree traversal function
* @cur: Pointer to current element
* @context: Pointer to the root node of the tree or subtree to
* be traversed.
* @level: The level of interest.
*
* RETURNS:
* Pointer to the next node on level @level
* or NULL when there is no next node.
*/
struct toptree *toptree_next(struct toptree *cur, struct toptree *context,
int level)
{
struct toptree *cur_context, *tmp;
if (!cur)
return NULL;
if (context->level == level)
return NULL;
tmp = toptree_next_sibling(cur);
if (tmp != NULL)
return tmp;
cur_context = cur;
while (cur_context->level < context->level - 1) {
/* Step up */
cur_context = cur_context->parent;
/* Step aside */
tmp = toptree_next_sibling(cur_context);
if (tmp != NULL) {
/* Step down */
tmp = toptree_first(tmp, level);
if (tmp != NULL)
return tmp;
}
}
return NULL;
}
/**
* toptree_count - Count descendants on specified level
* @context: Pointer to node whose descendants are to be considered
* @level: Only descendants on the specified level will be counted
*
* RETURNS:
* Number of descendants on the specified level
*/
int toptree_count(struct toptree *context, int level)
{
struct toptree *cur;
int cnt = 0;
toptree_for_each(cur, context, level)
cnt++;
return cnt;
}
/* SPDX-License-Identifier: GPL-2.0 */
/*
* NUMA support for s390
*
* A tree structure used for machine topology mangling
*
* Copyright IBM Corp. 2015
*/
#ifndef S390_TOPTREE_H
#define S390_TOPTREE_H
#include <linux/cpumask.h>
#include <linux/list.h>
struct toptree {
int level;
int id;
cpumask_t mask;
struct toptree *parent;
struct list_head sibling;
struct list_head children;
};
struct toptree *toptree_alloc(int level, int id);
void toptree_free(struct toptree *cand);
void toptree_update_mask(struct toptree *cand);
void toptree_unify(struct toptree *cand);
struct toptree *toptree_get_child(struct toptree *cand, int id);
void toptree_move(struct toptree *cand, struct toptree *target);
int toptree_count(struct toptree *context, int level);
struct toptree *toptree_first(struct toptree *context, int level);
struct toptree *toptree_next(struct toptree *cur, struct toptree *context,
int level);
#define toptree_for_each_child(child, ptree) \
list_for_each_entry(child, &ptree->children, sibling)
#define toptree_for_each_child_safe(child, ptmp, ptree) \
list_for_each_entry_safe(child, ptmp, &ptree->children, sibling)
#define toptree_is_last(ptree) \
((ptree->parent == NULL) || \
(ptree->parent->children.prev == &ptree->sibling))
#define toptree_for_each(ptree, cont, ttype) \
for (ptree = toptree_first(cont, ttype); \
ptree != NULL; \
ptree = toptree_next(ptree, cont, ttype))
#define toptree_for_each_safe(ptree, tmp, cont, ttype) \
for (ptree = toptree_first(cont, ttype), \
tmp = toptree_next(ptree, cont, ttype); \
ptree != NULL; \
ptree = tmp, \
tmp = toptree_next(ptree, cont, ttype))
#define toptree_for_each_sibling(ptree, start) \
toptree_for_each(ptree, start->parent, start->level)
#endif /* S390_TOPTREE_H */
......@@ -406,7 +406,7 @@ static void __init add_memory_merged(u16 rn)
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);
add_memory(0, addr, block_size);
skip_add:
first_rn = rn;
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