diff options
Diffstat (limited to 'arch/x86/mm/numa.c')
-rw-r--r-- | arch/x86/mm/numa.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c new file mode 100644 index 000000000000..f3a19e939e80 --- /dev/null +++ b/arch/x86/mm/numa.c | |||
@@ -0,0 +1,71 @@ | |||
1 | /* Common code for 32 and 64-bit NUMA */ | ||
2 | #include <linux/topology.h> | ||
3 | #include <linux/module.h> | ||
4 | #include <linux/bootmem.h> | ||
5 | |||
6 | #ifdef CONFIG_DEBUG_PER_CPU_MAPS | ||
7 | # define DBG(x...) printk(KERN_DEBUG x) | ||
8 | #else | ||
9 | # define DBG(x...) | ||
10 | #endif | ||
11 | |||
12 | /* | ||
13 | * Which logical CPUs are on which nodes | ||
14 | */ | ||
15 | cpumask_t *node_to_cpumask_map; | ||
16 | EXPORT_SYMBOL(node_to_cpumask_map); | ||
17 | |||
18 | /* | ||
19 | * Allocate node_to_cpumask_map based on number of available nodes | ||
20 | * Requires node_possible_map to be valid. | ||
21 | * | ||
22 | * Note: node_to_cpumask() is not valid until after this is done. | ||
23 | * (Use CONFIG_DEBUG_PER_CPU_MAPS to check this.) | ||
24 | */ | ||
25 | void __init setup_node_to_cpumask_map(void) | ||
26 | { | ||
27 | unsigned int node, num = 0; | ||
28 | cpumask_t *map; | ||
29 | |||
30 | /* setup nr_node_ids if not done yet */ | ||
31 | if (nr_node_ids == MAX_NUMNODES) { | ||
32 | for_each_node_mask(node, node_possible_map) | ||
33 | num = node; | ||
34 | nr_node_ids = num + 1; | ||
35 | } | ||
36 | |||
37 | /* allocate the map */ | ||
38 | map = alloc_bootmem_low(nr_node_ids * sizeof(cpumask_t)); | ||
39 | DBG("node_to_cpumask_map at %p for %d nodes\n", map, nr_node_ids); | ||
40 | |||
41 | pr_debug("Node to cpumask map at %p for %d nodes\n", | ||
42 | map, nr_node_ids); | ||
43 | |||
44 | /* node_to_cpumask() will now work */ | ||
45 | node_to_cpumask_map = map; | ||
46 | } | ||
47 | |||
48 | #ifdef CONFIG_DEBUG_PER_CPU_MAPS | ||
49 | /* | ||
50 | * Returns a pointer to the bitmask of CPUs on Node 'node'. | ||
51 | */ | ||
52 | const cpumask_t *cpumask_of_node(int node) | ||
53 | { | ||
54 | if (node_to_cpumask_map == NULL) { | ||
55 | printk(KERN_WARNING | ||
56 | "cpumask_of_node(%d): no node_to_cpumask_map!\n", | ||
57 | node); | ||
58 | dump_stack(); | ||
59 | return cpu_online_mask; | ||
60 | } | ||
61 | if (node >= nr_node_ids) { | ||
62 | printk(KERN_WARNING | ||
63 | "cpumask_of_node(%d): node > nr_node_ids(%d)\n", | ||
64 | node, nr_node_ids); | ||
65 | dump_stack(); | ||
66 | return cpu_none_mask; | ||
67 | } | ||
68 | return &node_to_cpumask_map[node]; | ||
69 | } | ||
70 | EXPORT_SYMBOL(cpumask_of_node); | ||
71 | #endif | ||