1 /* Common code for 32 and 64-bit NUMA */
2 #include <linux/topology.h>
3 #include <linux/module.h>
4 #include <linux/bootmem.h>
8 int __initdata numa_off
;
10 static __init
int numa_setup(char *opt
)
14 if (!strncmp(opt
, "off", 3))
16 #ifdef CONFIG_NUMA_EMU
17 if (!strncmp(opt
, "fake=", 5))
18 numa_emu_cmdline(opt
+ 5);
20 #ifdef CONFIG_ACPI_NUMA
21 if (!strncmp(opt
, "noacpi", 6))
26 early_param("numa", numa_setup
);
29 * Which logical CPUs are on which nodes
31 cpumask_var_t node_to_cpumask_map
[MAX_NUMNODES
];
32 EXPORT_SYMBOL(node_to_cpumask_map
);
35 * Allocate node_to_cpumask_map based on number of available nodes
36 * Requires node_possible_map to be valid.
38 * Note: node_to_cpumask() is not valid until after this is done.
39 * (Use CONFIG_DEBUG_PER_CPU_MAPS to check this.)
41 void __init
setup_node_to_cpumask_map(void)
43 unsigned int node
, num
= 0;
45 /* setup nr_node_ids if not done yet */
46 if (nr_node_ids
== MAX_NUMNODES
) {
47 for_each_node_mask(node
, node_possible_map
)
49 nr_node_ids
= num
+ 1;
52 /* allocate the map */
53 for (node
= 0; node
< nr_node_ids
; node
++)
54 alloc_bootmem_cpumask_var(&node_to_cpumask_map
[node
]);
56 /* cpumask_of_node() will now work */
57 pr_debug("Node to cpumask map for %d nodes\n", nr_node_ids
);
60 #ifdef CONFIG_DEBUG_PER_CPU_MAPS
62 * Returns a pointer to the bitmask of CPUs on Node 'node'.
64 const struct cpumask
*cpumask_of_node(int node
)
66 if (node
>= nr_node_ids
) {
68 "cpumask_of_node(%d): node > nr_node_ids(%d)\n",
73 if (node_to_cpumask_map
[node
] == NULL
) {
75 "cpumask_of_node(%d): no node_to_cpumask_map!\n",
78 return cpu_online_mask
;
80 return node_to_cpumask_map
[node
];
82 EXPORT_SYMBOL(cpumask_of_node
);