Commit | Line | Data |
---|---|---|
71ee73e7 RR |
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 | ||
71ee73e7 RR |
6 | /* |
7 | * Which logical CPUs are on which nodes | |
8 | */ | |
c032ef60 | 9 | cpumask_var_t node_to_cpumask_map[MAX_NUMNODES]; |
71ee73e7 RR |
10 | EXPORT_SYMBOL(node_to_cpumask_map); |
11 | ||
12 | /* | |
13 | * Allocate node_to_cpumask_map based on number of available nodes | |
14 | * Requires node_possible_map to be valid. | |
15 | * | |
16 | * Note: node_to_cpumask() is not valid until after this is done. | |
17 | * (Use CONFIG_DEBUG_PER_CPU_MAPS to check this.) | |
18 | */ | |
19 | void __init setup_node_to_cpumask_map(void) | |
20 | { | |
21 | unsigned int node, num = 0; | |
71ee73e7 RR |
22 | |
23 | /* setup nr_node_ids if not done yet */ | |
24 | if (nr_node_ids == MAX_NUMNODES) { | |
25 | for_each_node_mask(node, node_possible_map) | |
26 | num = node; | |
27 | nr_node_ids = num + 1; | |
28 | } | |
29 | ||
30 | /* allocate the map */ | |
c032ef60 RR |
31 | for (node = 0; node < nr_node_ids; node++) |
32 | alloc_bootmem_cpumask_var(&node_to_cpumask_map[node]); | |
71ee73e7 | 33 | |
c032ef60 RR |
34 | /* cpumask_of_node() will now work */ |
35 | pr_debug("Node to cpumask map for %d nodes\n", nr_node_ids); | |
71ee73e7 RR |
36 | } |
37 | ||
38 | #ifdef CONFIG_DEBUG_PER_CPU_MAPS | |
39 | /* | |
40 | * Returns a pointer to the bitmask of CPUs on Node 'node'. | |
41 | */ | |
73e907de | 42 | const struct cpumask *cpumask_of_node(int node) |
71ee73e7 | 43 | { |
71ee73e7 RR |
44 | if (node >= nr_node_ids) { |
45 | printk(KERN_WARNING | |
46 | "cpumask_of_node(%d): node > nr_node_ids(%d)\n", | |
47 | node, nr_node_ids); | |
48 | dump_stack(); | |
49 | return cpu_none_mask; | |
50 | } | |
c032ef60 RR |
51 | if (node_to_cpumask_map[node] == NULL) { |
52 | printk(KERN_WARNING | |
53 | "cpumask_of_node(%d): no node_to_cpumask_map!\n", | |
54 | node); | |
55 | dump_stack(); | |
56 | return cpu_online_mask; | |
57 | } | |
0b966252 | 58 | return node_to_cpumask_map[node]; |
71ee73e7 RR |
59 | } |
60 | EXPORT_SYMBOL(cpumask_of_node); | |
61 | #endif |