diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2009-03-30 23:03:50 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2009-03-30 23:03:50 -0400 |
commit | 558f6ab9106e6be701acb0257e7171df1bbccf04 (patch) | |
tree | 6e811633baeb676693c493f6c82bf785cab2771d /arch/x86/mm/numa.c | |
parent | 15f7176eb1cccec0a332541285ee752b935c1c85 (diff) | |
parent | 65fb0d23fcddd8697c871047b700c78817bdaa43 (diff) |
Merge branch 'cpumask-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
Conflicts:
arch/x86/include/asm/topology.h
drivers/oprofile/buffer_sync.c
(Both cases: changed in Linus' tree, removed in Ingo's).
Diffstat (limited to 'arch/x86/mm/numa.c')
-rw-r--r-- | arch/x86/mm/numa.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c new file mode 100644 index 000000000000..550df481accd --- /dev/null +++ b/arch/x86/mm/numa.c | |||
@@ -0,0 +1,67 @@ | |||
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_var_t node_to_cpumask_map[MAX_NUMNODES]; | ||
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 | |||
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; | ||
34 | } | ||
35 | |||
36 | /* allocate the map */ | ||
37 | for (node = 0; node < nr_node_ids; node++) | ||
38 | alloc_bootmem_cpumask_var(&node_to_cpumask_map[node]); | ||
39 | |||
40 | /* cpumask_of_node() will now work */ | ||
41 | pr_debug("Node to cpumask map for %d nodes\n", nr_node_ids); | ||
42 | } | ||
43 | |||
44 | #ifdef CONFIG_DEBUG_PER_CPU_MAPS | ||
45 | /* | ||
46 | * Returns a pointer to the bitmask of CPUs on Node 'node'. | ||
47 | */ | ||
48 | const struct cpumask *cpumask_of_node(int node) | ||
49 | { | ||
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; | ||
56 | } | ||
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; | ||
63 | } | ||
64 | return node_to_cpumask_map[node]; | ||
65 | } | ||
66 | EXPORT_SYMBOL(cpumask_of_node); | ||
67 | #endif | ||