Btrfs: avoid taking the trans_mutex in btrfs_end_transaction
[linux-2.6/kvm.git] / arch / x86 / mm / numa.c
blobebf6d7887a38fa54481b6b7645e42bb7c59499a7
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 #include <asm/numa.h>
6 #include <asm/acpi.h>
8 int __initdata numa_off;
10 static __init int numa_setup(char *opt)
12 if (!opt)
13 return -EINVAL;
14 if (!strncmp(opt, "off", 3))
15 numa_off = 1;
16 #ifdef CONFIG_NUMA_EMU
17 if (!strncmp(opt, "fake=", 5))
18 numa_emu_cmdline(opt + 5);
19 #endif
20 #ifdef CONFIG_ACPI_NUMA
21 if (!strncmp(opt, "noacpi", 6))
22 acpi_numa = -1;
23 #endif
24 return 0;
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)
48 num = node;
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) {
67 printk(KERN_WARNING
68 "cpumask_of_node(%d): node > nr_node_ids(%d)\n",
69 node, nr_node_ids);
70 dump_stack();
71 return cpu_none_mask;
73 if (node_to_cpumask_map[node] == NULL) {
74 printk(KERN_WARNING
75 "cpumask_of_node(%d): no node_to_cpumask_map!\n",
76 node);
77 dump_stack();
78 return cpu_online_mask;
80 return node_to_cpumask_map[node];
82 EXPORT_SYMBOL(cpumask_of_node);
83 #endif