diff options
author | Anton Blanchard <anton@samba.org> | 2010-04-26 11:32:43 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2010-05-06 03:41:58 -0400 |
commit | 25863de07af9cb90e6365cc8216bdd17f2394515 (patch) | |
tree | ac765e8b06006efea240ce287d587103341bf380 /arch | |
parent | 8729faaa5e87557876c02f1665d517e2b41299f1 (diff) |
powerpc/cpumask: Convert NUMA code to new cpumask API
Convert NUMA code to new cpumask API. We shift the node to cpumask
setup code until after we complete bootmem allocation so we can
dynamically allocate the cpumasks.
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/include/asm/mmzone.h | 2 | ||||
-rw-r--r-- | arch/powerpc/include/asm/topology.h | 2 | ||||
-rw-r--r-- | arch/powerpc/mm/numa.c | 58 |
3 files changed, 47 insertions, 15 deletions
diff --git a/arch/powerpc/include/asm/mmzone.h b/arch/powerpc/include/asm/mmzone.h index 35acac90c8ca..aac87cbceb57 100644 --- a/arch/powerpc/include/asm/mmzone.h +++ b/arch/powerpc/include/asm/mmzone.h | |||
@@ -30,7 +30,7 @@ extern struct pglist_data *node_data[]; | |||
30 | */ | 30 | */ |
31 | 31 | ||
32 | extern int numa_cpu_lookup_table[]; | 32 | extern int numa_cpu_lookup_table[]; |
33 | extern cpumask_t numa_cpumask_lookup_table[]; | 33 | extern cpumask_var_t node_to_cpumask_map[]; |
34 | #ifdef CONFIG_MEMORY_HOTPLUG | 34 | #ifdef CONFIG_MEMORY_HOTPLUG |
35 | extern unsigned long max_pfn; | 35 | extern unsigned long max_pfn; |
36 | #endif | 36 | #endif |
diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h index 789599b69960..84ad11f65dc2 100644 --- a/arch/powerpc/include/asm/topology.h +++ b/arch/powerpc/include/asm/topology.h | |||
@@ -29,7 +29,7 @@ static inline int cpu_to_node(int cpu) | |||
29 | 29 | ||
30 | #define cpumask_of_node(node) ((node) == -1 ? \ | 30 | #define cpumask_of_node(node) ((node) == -1 ? \ |
31 | cpu_all_mask : \ | 31 | cpu_all_mask : \ |
32 | &numa_cpumask_lookup_table[node]) | 32 | node_to_cpumask_map[node]) |
33 | 33 | ||
34 | int of_node_to_nid(struct device_node *device); | 34 | int of_node_to_nid(struct device_node *device); |
35 | 35 | ||
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index 64c00227b997..d68491b31e38 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c | |||
@@ -33,16 +33,41 @@ static int numa_debug; | |||
33 | #define dbg(args...) if (numa_debug) { printk(KERN_INFO args); } | 33 | #define dbg(args...) if (numa_debug) { printk(KERN_INFO args); } |
34 | 34 | ||
35 | int numa_cpu_lookup_table[NR_CPUS]; | 35 | int numa_cpu_lookup_table[NR_CPUS]; |
36 | cpumask_t numa_cpumask_lookup_table[MAX_NUMNODES]; | 36 | cpumask_var_t node_to_cpumask_map[MAX_NUMNODES]; |
37 | struct pglist_data *node_data[MAX_NUMNODES]; | 37 | struct pglist_data *node_data[MAX_NUMNODES]; |
38 | 38 | ||
39 | EXPORT_SYMBOL(numa_cpu_lookup_table); | 39 | EXPORT_SYMBOL(numa_cpu_lookup_table); |
40 | EXPORT_SYMBOL(numa_cpumask_lookup_table); | 40 | EXPORT_SYMBOL(node_to_cpumask_map); |
41 | EXPORT_SYMBOL(node_data); | 41 | EXPORT_SYMBOL(node_data); |
42 | 42 | ||
43 | static int min_common_depth; | 43 | static int min_common_depth; |
44 | static int n_mem_addr_cells, n_mem_size_cells; | 44 | static int n_mem_addr_cells, n_mem_size_cells; |
45 | 45 | ||
46 | /* | ||
47 | * Allocate node_to_cpumask_map based on number of available nodes | ||
48 | * Requires node_possible_map to be valid. | ||
49 | * | ||
50 | * Note: node_to_cpumask() is not valid until after this is done. | ||
51 | */ | ||
52 | static void __init setup_node_to_cpumask_map(void) | ||
53 | { | ||
54 | unsigned int node, num = 0; | ||
55 | |||
56 | /* setup nr_node_ids if not done yet */ | ||
57 | if (nr_node_ids == MAX_NUMNODES) { | ||
58 | for_each_node_mask(node, node_possible_map) | ||
59 | num = node; | ||
60 | nr_node_ids = num + 1; | ||
61 | } | ||
62 | |||
63 | /* allocate the map */ | ||
64 | for (node = 0; node < nr_node_ids; node++) | ||
65 | alloc_bootmem_cpumask_var(&node_to_cpumask_map[node]); | ||
66 | |||
67 | /* cpumask_of_node() will now work */ | ||
68 | dbg("Node to cpumask map for %d nodes\n", nr_node_ids); | ||
69 | } | ||
70 | |||
46 | static int __cpuinit fake_numa_create_new_node(unsigned long end_pfn, | 71 | static int __cpuinit fake_numa_create_new_node(unsigned long end_pfn, |
47 | unsigned int *nid) | 72 | unsigned int *nid) |
48 | { | 73 | { |
@@ -138,8 +163,8 @@ static void __cpuinit map_cpu_to_node(int cpu, int node) | |||
138 | 163 | ||
139 | dbg("adding cpu %d to node %d\n", cpu, node); | 164 | dbg("adding cpu %d to node %d\n", cpu, node); |
140 | 165 | ||
141 | if (!(cpu_isset(cpu, numa_cpumask_lookup_table[node]))) | 166 | if (!(cpumask_test_cpu(cpu, node_to_cpumask_map[node]))) |
142 | cpu_set(cpu, numa_cpumask_lookup_table[node]); | 167 | cpumask_set_cpu(cpu, node_to_cpumask_map[node]); |
143 | } | 168 | } |
144 | 169 | ||
145 | #ifdef CONFIG_HOTPLUG_CPU | 170 | #ifdef CONFIG_HOTPLUG_CPU |
@@ -149,8 +174,8 @@ static void unmap_cpu_from_node(unsigned long cpu) | |||
149 | 174 | ||
150 | dbg("removing cpu %lu from node %d\n", cpu, node); | 175 | dbg("removing cpu %lu from node %d\n", cpu, node); |
151 | 176 | ||
152 | if (cpu_isset(cpu, numa_cpumask_lookup_table[node])) { | 177 | if (cpumask_test_cpu(cpu, node_to_cpumask_map[node])) { |
153 | cpu_clear(cpu, numa_cpumask_lookup_table[node]); | 178 | cpumask_set_cpu(cpu, node_to_cpumask_map[node]); |
154 | } else { | 179 | } else { |
155 | printk(KERN_ERR "WARNING: cpu %lu not found in node %d\n", | 180 | printk(KERN_ERR "WARNING: cpu %lu not found in node %d\n", |
156 | cpu, node); | 181 | cpu, node); |
@@ -737,8 +762,9 @@ void __init dump_numa_cpu_topology(void) | |||
737 | * If we used a CPU iterator here we would miss printing | 762 | * If we used a CPU iterator here we would miss printing |
738 | * the holes in the cpumap. | 763 | * the holes in the cpumap. |
739 | */ | 764 | */ |
740 | for (cpu = 0; cpu < NR_CPUS; cpu++) { | 765 | for (cpu = 0; cpu < nr_cpu_ids; cpu++) { |
741 | if (cpu_isset(cpu, numa_cpumask_lookup_table[node])) { | 766 | if (cpumask_test_cpu(cpu, |
767 | node_to_cpumask_map[node])) { | ||
742 | if (count == 0) | 768 | if (count == 0) |
743 | printk(" %u", cpu); | 769 | printk(" %u", cpu); |
744 | ++count; | 770 | ++count; |
@@ -750,7 +776,7 @@ void __init dump_numa_cpu_topology(void) | |||
750 | } | 776 | } |
751 | 777 | ||
752 | if (count > 1) | 778 | if (count > 1) |
753 | printk("-%u", NR_CPUS - 1); | 779 | printk("-%u", nr_cpu_ids - 1); |
754 | printk("\n"); | 780 | printk("\n"); |
755 | } | 781 | } |
756 | } | 782 | } |
@@ -926,10 +952,6 @@ void __init do_init_bootmem(void) | |||
926 | else | 952 | else |
927 | dump_numa_memory_topology(); | 953 | dump_numa_memory_topology(); |
928 | 954 | ||
929 | register_cpu_notifier(&ppc64_numa_nb); | ||
930 | cpu_numa_callback(&ppc64_numa_nb, CPU_UP_PREPARE, | ||
931 | (void *)(unsigned long)boot_cpuid); | ||
932 | |||
933 | for_each_online_node(nid) { | 955 | for_each_online_node(nid) { |
934 | unsigned long start_pfn, end_pfn; | 956 | unsigned long start_pfn, end_pfn; |
935 | void *bootmem_vaddr; | 957 | void *bootmem_vaddr; |
@@ -983,6 +1005,16 @@ void __init do_init_bootmem(void) | |||
983 | } | 1005 | } |
984 | 1006 | ||
985 | init_bootmem_done = 1; | 1007 | init_bootmem_done = 1; |
1008 | |||
1009 | /* | ||
1010 | * Now bootmem is initialised we can create the node to cpumask | ||
1011 | * lookup tables and setup the cpu callback to populate them. | ||
1012 | */ | ||
1013 | setup_node_to_cpumask_map(); | ||
1014 | |||
1015 | register_cpu_notifier(&ppc64_numa_nb); | ||
1016 | cpu_numa_callback(&ppc64_numa_nb, CPU_UP_PREPARE, | ||
1017 | (void *)(unsigned long)boot_cpuid); | ||
986 | } | 1018 | } |
987 | 1019 | ||
988 | void __init paging_init(void) | 1020 | void __init paging_init(void) |