Linux 2.6.31.6
[linux/fpc-iii.git] / arch / x86 / mm / numa.c
blob550df481accd58d8ce23e7c96549f0507b1365b8
1 /* Common code for 32 and 64-bit NUMA */
2 #include <linux/topology.h>
3 #include <linux/module.h>
4 #include <linux/bootmem.h>
6 #ifdef CONFIG_DEBUG_PER_CPU_MAPS
7 # define DBG(x...) printk(KERN_DEBUG x)
8 #else
9 # define DBG(x...)
10 #endif
13 * Which logical CPUs are on which nodes
15 cpumask_var_t node_to_cpumask_map[MAX_NUMNODES];
16 EXPORT_SYMBOL(node_to_cpumask_map);
19 * Allocate node_to_cpumask_map based on number of available nodes
20 * Requires node_possible_map to be valid.
22 * Note: node_to_cpumask() is not valid until after this is done.
23 * (Use CONFIG_DEBUG_PER_CPU_MAPS to check this.)
25 void __init setup_node_to_cpumask_map(void)
27 unsigned int node, num = 0;
29 /* setup nr_node_ids if not done yet */
30 if (nr_node_ids == MAX_NUMNODES) {
31 for_each_node_mask(node, node_possible_map)
32 num = node;
33 nr_node_ids = num + 1;
36 /* allocate the map */
37 for (node = 0; node < nr_node_ids; node++)
38 alloc_bootmem_cpumask_var(&node_to_cpumask_map[node]);
40 /* cpumask_of_node() will now work */
41 pr_debug("Node to cpumask map for %d nodes\n", nr_node_ids);
44 #ifdef CONFIG_DEBUG_PER_CPU_MAPS
46 * Returns a pointer to the bitmask of CPUs on Node 'node'.
48 const struct cpumask *cpumask_of_node(int node)
50 if (node >= nr_node_ids) {
51 printk(KERN_WARNING
52 "cpumask_of_node(%d): node > nr_node_ids(%d)\n",
53 node, nr_node_ids);
54 dump_stack();
55 return cpu_none_mask;
57 if (node_to_cpumask_map[node] == NULL) {
58 printk(KERN_WARNING
59 "cpumask_of_node(%d): no node_to_cpumask_map!\n",
60 node);
61 dump_stack();
62 return cpu_online_mask;
64 return node_to_cpumask_map[node];
66 EXPORT_SYMBOL(cpumask_of_node);
67 #endif