x86: unify 32 and 64-bit node_to_cpumask_map
Impact: cleanup We take the 64-bit code and use it on 32-bit as well. The new file is called mm/numa.c. In a minor cleanup, we use cpu_none_mask instead of declaring a local cpu_mask_none. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
b9c4398ed4
commit
71ee73e722
|
@ -44,9 +44,6 @@
|
|||
|
||||
#ifdef CONFIG_X86_32
|
||||
|
||||
/* Mappings between node number and cpus on that node. */
|
||||
extern cpumask_t node_to_cpumask_map[];
|
||||
|
||||
/* Mappings between logical cpu number and node number */
|
||||
extern int cpu_to_node_map[];
|
||||
|
||||
|
@ -57,19 +54,8 @@ static inline int cpu_to_node(int cpu)
|
|||
}
|
||||
#define early_cpu_to_node(cpu) cpu_to_node(cpu)
|
||||
|
||||
/* Returns a bitmask of CPUs on Node 'node'. */
|
||||
static inline const struct cpumask *cpumask_of_node(int node)
|
||||
{
|
||||
return &node_to_cpumask_map[node];
|
||||
}
|
||||
|
||||
static inline void setup_node_to_cpumask_map(void) { }
|
||||
|
||||
#else /* CONFIG_X86_64 */
|
||||
|
||||
/* Mappings between node number and cpus on that node. */
|
||||
extern cpumask_t *node_to_cpumask_map;
|
||||
|
||||
/* Mappings between logical cpu number and node number */
|
||||
DECLARE_EARLY_PER_CPU(int, x86_cpu_to_node_map);
|
||||
|
||||
|
@ -80,7 +66,6 @@ DECLARE_PER_CPU(int, node_number);
|
|||
#ifdef CONFIG_DEBUG_PER_CPU_MAPS
|
||||
extern int cpu_to_node(int cpu);
|
||||
extern int early_cpu_to_node(int cpu);
|
||||
extern const cpumask_t *cpumask_of_node(int node);
|
||||
|
||||
#else /* !CONFIG_DEBUG_PER_CPU_MAPS */
|
||||
|
||||
|
@ -96,18 +81,25 @@ static inline int early_cpu_to_node(int cpu)
|
|||
return early_per_cpu(x86_cpu_to_node_map, cpu);
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_DEBUG_PER_CPU_MAPS */
|
||||
|
||||
#endif /* CONFIG_X86_64 */
|
||||
|
||||
/* Mappings between node number and cpus on that node. */
|
||||
extern cpumask_t *node_to_cpumask_map;
|
||||
|
||||
#ifdef CONFIG_DEBUG_PER_CPU_MAPS
|
||||
extern const cpumask_t *cpumask_of_node(int node);
|
||||
#else
|
||||
/* Returns a pointer to the cpumask of CPUs on Node 'node'. */
|
||||
static inline const cpumask_t *cpumask_of_node(int node)
|
||||
{
|
||||
return &node_to_cpumask_map[node];
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_DEBUG_PER_CPU_MAPS */
|
||||
#endif
|
||||
|
||||
extern void setup_node_to_cpumask_map(void);
|
||||
|
||||
#endif /* CONFIG_X86_64 */
|
||||
|
||||
/*
|
||||
* Returns the number of the node containing Node 'node'. This
|
||||
* architecture is flat, so it is a pretty simple function!
|
||||
|
|
|
@ -115,11 +115,6 @@ EXPORT_PER_CPU_SYMBOL(cpu_info);
|
|||
atomic_t init_deasserted;
|
||||
|
||||
#if defined(CONFIG_NUMA) && defined(CONFIG_X86_32)
|
||||
|
||||
/* which logical CPUs are on which nodes */
|
||||
cpumask_t node_to_cpumask_map[MAX_NUMNODES] __read_mostly =
|
||||
{ [0 ... MAX_NUMNODES-1] = CPU_MASK_NONE };
|
||||
EXPORT_SYMBOL(node_to_cpumask_map);
|
||||
/* which node each logical CPU is on */
|
||||
int cpu_to_node_map[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = 0 };
|
||||
EXPORT_SYMBOL(cpu_to_node_map);
|
||||
|
|
|
@ -14,7 +14,7 @@ obj-$(CONFIG_MMIOTRACE) += mmiotrace.o
|
|||
mmiotrace-y := kmmio.o pf_in.o mmio-mod.o
|
||||
obj-$(CONFIG_MMIOTRACE_TEST) += testmmiotrace.o
|
||||
|
||||
obj-$(CONFIG_NUMA) += numa_$(BITS).o
|
||||
obj-$(CONFIG_NUMA) += numa.o numa_$(BITS).o
|
||||
obj-$(CONFIG_K8_NUMA) += k8topology_64.o
|
||||
obj-$(CONFIG_ACPI_NUMA) += srat_$(BITS).o
|
||||
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
/* Common code for 32 and 64-bit NUMA */
|
||||
#include <linux/topology.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/bootmem.h>
|
||||
|
||||
#ifdef CONFIG_DEBUG_PER_CPU_MAPS
|
||||
# define DBG(x...) printk(KERN_DEBUG x)
|
||||
#else
|
||||
# define DBG(x...)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Which logical CPUs are on which nodes
|
||||
*/
|
||||
cpumask_t *node_to_cpumask_map;
|
||||
EXPORT_SYMBOL(node_to_cpumask_map);
|
||||
|
||||
/*
|
||||
* Allocate node_to_cpumask_map based on number of available nodes
|
||||
* Requires node_possible_map to be valid.
|
||||
*
|
||||
* Note: node_to_cpumask() is not valid until after this is done.
|
||||
* (Use CONFIG_DEBUG_PER_CPU_MAPS to check this.)
|
||||
*/
|
||||
void __init setup_node_to_cpumask_map(void)
|
||||
{
|
||||
unsigned int node, num = 0;
|
||||
cpumask_t *map;
|
||||
|
||||
/* setup nr_node_ids if not done yet */
|
||||
if (nr_node_ids == MAX_NUMNODES) {
|
||||
for_each_node_mask(node, node_possible_map)
|
||||
num = node;
|
||||
nr_node_ids = num + 1;
|
||||
}
|
||||
|
||||
/* allocate the map */
|
||||
map = alloc_bootmem_low(nr_node_ids * sizeof(cpumask_t));
|
||||
DBG("node_to_cpumask_map at %p for %d nodes\n", map, nr_node_ids);
|
||||
|
||||
pr_debug("Node to cpumask map at %p for %d nodes\n",
|
||||
map, nr_node_ids);
|
||||
|
||||
/* node_to_cpumask() will now work */
|
||||
node_to_cpumask_map = map;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEBUG_PER_CPU_MAPS
|
||||
/*
|
||||
* Returns a pointer to the bitmask of CPUs on Node 'node'.
|
||||
*/
|
||||
const cpumask_t *cpumask_of_node(int node)
|
||||
{
|
||||
if (node_to_cpumask_map == NULL) {
|
||||
printk(KERN_WARNING
|
||||
"cpumask_of_node(%d): no node_to_cpumask_map!\n",
|
||||
node);
|
||||
dump_stack();
|
||||
return cpu_online_mask;
|
||||
}
|
||||
if (node >= nr_node_ids) {
|
||||
printk(KERN_WARNING
|
||||
"cpumask_of_node(%d): node > nr_node_ids(%d)\n",
|
||||
node, nr_node_ids);
|
||||
dump_stack();
|
||||
return cpu_none_mask;
|
||||
}
|
||||
return &node_to_cpumask_map[node];
|
||||
}
|
||||
EXPORT_SYMBOL(cpumask_of_node);
|
||||
#endif
|
|
@ -20,12 +20,6 @@
|
|||
#include <asm/acpi.h>
|
||||
#include <asm/k8.h>
|
||||
|
||||
#ifdef CONFIG_DEBUG_PER_CPU_MAPS
|
||||
# define DBG(x...) printk(KERN_DEBUG x)
|
||||
#else
|
||||
# define DBG(x...)
|
||||
#endif
|
||||
|
||||
struct pglist_data *node_data[MAX_NUMNODES] __read_mostly;
|
||||
EXPORT_SYMBOL(node_data);
|
||||
|
||||
|
@ -48,12 +42,6 @@ EXPORT_PER_CPU_SYMBOL(node_number);
|
|||
DEFINE_EARLY_PER_CPU(int, x86_cpu_to_node_map, NUMA_NO_NODE);
|
||||
EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_node_map);
|
||||
|
||||
/*
|
||||
* Which logical CPUs are on which nodes
|
||||
*/
|
||||
cpumask_t *node_to_cpumask_map;
|
||||
EXPORT_SYMBOL(node_to_cpumask_map);
|
||||
|
||||
/*
|
||||
* Given a shift value, try to populate memnodemap[]
|
||||
* Returns :
|
||||
|
@ -661,36 +649,6 @@ void __init init_cpu_to_node(void)
|
|||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Allocate node_to_cpumask_map based on number of available nodes
|
||||
* Requires node_possible_map to be valid.
|
||||
*
|
||||
* Note: node_to_cpumask() is not valid until after this is done.
|
||||
* (Use CONFIG_DEBUG_PER_CPU_MAPS to check this.)
|
||||
*/
|
||||
void __init setup_node_to_cpumask_map(void)
|
||||
{
|
||||
unsigned int node, num = 0;
|
||||
cpumask_t *map;
|
||||
|
||||
/* setup nr_node_ids if not done yet */
|
||||
if (nr_node_ids == MAX_NUMNODES) {
|
||||
for_each_node_mask(node, node_possible_map)
|
||||
num = node;
|
||||
nr_node_ids = num + 1;
|
||||
}
|
||||
|
||||
/* allocate the map */
|
||||
map = alloc_bootmem_low(nr_node_ids * sizeof(cpumask_t));
|
||||
DBG("node_to_cpumask_map at %p for %d nodes\n", map, nr_node_ids);
|
||||
|
||||
pr_debug("Node to cpumask map at %p for %d nodes\n",
|
||||
map, nr_node_ids);
|
||||
|
||||
/* node_to_cpumask() will now work */
|
||||
node_to_cpumask_map = map;
|
||||
}
|
||||
|
||||
void __cpuinit numa_set_node(int cpu, int node)
|
||||
{
|
||||
int *cpu_to_node_map = early_per_cpu_ptr(x86_cpu_to_node_map);
|
||||
|
@ -799,33 +757,6 @@ int early_cpu_to_node(int cpu)
|
|||
return per_cpu(x86_cpu_to_node_map, cpu);
|
||||
}
|
||||
|
||||
|
||||
/* empty cpumask */
|
||||
static const cpumask_t cpu_mask_none;
|
||||
|
||||
/*
|
||||
* Returns a pointer to the bitmask of CPUs on Node 'node'.
|
||||
*/
|
||||
const cpumask_t *cpumask_of_node(int node)
|
||||
{
|
||||
if (node_to_cpumask_map == NULL) {
|
||||
printk(KERN_WARNING
|
||||
"cpumask_of_node(%d): no node_to_cpumask_map!\n",
|
||||
node);
|
||||
dump_stack();
|
||||
return (const cpumask_t *)&cpu_online_map;
|
||||
}
|
||||
if (node >= nr_node_ids) {
|
||||
printk(KERN_WARNING
|
||||
"cpumask_of_node(%d): node > nr_node_ids(%d)\n",
|
||||
node, nr_node_ids);
|
||||
dump_stack();
|
||||
return &cpu_mask_none;
|
||||
}
|
||||
return &node_to_cpumask_map[node];
|
||||
}
|
||||
EXPORT_SYMBOL(cpumask_of_node);
|
||||
|
||||
/*
|
||||
* --------- end of debug versions of the numa functions ---------
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue