]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
powerpc/cpumask: Convert NUMA code to new cpumask API
authorAnton Blanchard <anton@samba.org>
Mon, 26 Apr 2010 15:32:43 +0000 (15:32 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Thu, 6 May 2010 07:41:58 +0000 (17:41 +1000)
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>
arch/powerpc/include/asm/mmzone.h
arch/powerpc/include/asm/topology.h
arch/powerpc/mm/numa.c

index 35acac90c8ca6b3b32500c07cfc2b9586020cf39..aac87cbceb573d3fef41007df14795063ed07b70 100644 (file)
@@ -30,7 +30,7 @@ extern struct pglist_data *node_data[];
  */
 
 extern int numa_cpu_lookup_table[];
-extern cpumask_t numa_cpumask_lookup_table[];
+extern cpumask_var_t node_to_cpumask_map[];
 #ifdef CONFIG_MEMORY_HOTPLUG
 extern unsigned long max_pfn;
 #endif
index 789599b699609150f0e14851d78e3f55f63b6c43..84ad11f65dc281e6eddd34b40396830f40afd130 100644 (file)
@@ -29,7 +29,7 @@ static inline int cpu_to_node(int cpu)
 
 #define cpumask_of_node(node) ((node) == -1 ?                          \
                               cpu_all_mask :                           \
-                              &numa_cpumask_lookup_table[node])
+                              node_to_cpumask_map[node])
 
 int of_node_to_nid(struct device_node *device);
 
index 64c00227b99786cab5ae38d6513c73db1b13fd8f..d68491b31e3814abf461246719b7fa404c62225d 100644 (file)
@@ -33,16 +33,41 @@ static int numa_debug;
 #define dbg(args...) if (numa_debug) { printk(KERN_INFO args); }
 
 int numa_cpu_lookup_table[NR_CPUS];
-cpumask_t numa_cpumask_lookup_table[MAX_NUMNODES];
+cpumask_var_t node_to_cpumask_map[MAX_NUMNODES];
 struct pglist_data *node_data[MAX_NUMNODES];
 
 EXPORT_SYMBOL(numa_cpu_lookup_table);
-EXPORT_SYMBOL(numa_cpumask_lookup_table);
+EXPORT_SYMBOL(node_to_cpumask_map);
 EXPORT_SYMBOL(node_data);
 
 static int min_common_depth;
 static int n_mem_addr_cells, n_mem_size_cells;
 
+/*
+ * Allocate node_to_cpumask_map based on number of available nodes
+ * Requires node_possible_map to be valid.
+ *
+ * Note: node_to_cpumask() is not valid until after this is done.
+ */
+static void __init setup_node_to_cpumask_map(void)
+{
+       unsigned int node, num = 0;
+
+       /* setup nr_node_ids if not done yet */
+       if (nr_node_ids == MAX_NUMNODES) {
+               for_each_node_mask(node, node_possible_map)
+                       num = node;
+               nr_node_ids = num + 1;
+       }
+
+       /* allocate the map */
+       for (node = 0; node < nr_node_ids; node++)
+               alloc_bootmem_cpumask_var(&node_to_cpumask_map[node]);
+
+       /* cpumask_of_node() will now work */
+       dbg("Node to cpumask map for %d nodes\n", nr_node_ids);
+}
+
 static int __cpuinit fake_numa_create_new_node(unsigned long end_pfn,
                                                unsigned int *nid)
 {
@@ -138,8 +163,8 @@ static void __cpuinit map_cpu_to_node(int cpu, int node)
 
        dbg("adding cpu %d to node %d\n", cpu, node);
 
-       if (!(cpu_isset(cpu, numa_cpumask_lookup_table[node])))
-               cpu_set(cpu, numa_cpumask_lookup_table[node]);
+       if (!(cpumask_test_cpu(cpu, node_to_cpumask_map[node])))
+               cpumask_set_cpu(cpu, node_to_cpumask_map[node]);
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
@@ -149,8 +174,8 @@ static void unmap_cpu_from_node(unsigned long cpu)
 
        dbg("removing cpu %lu from node %d\n", cpu, node);
 
-       if (cpu_isset(cpu, numa_cpumask_lookup_table[node])) {
-               cpu_clear(cpu, numa_cpumask_lookup_table[node]);
+       if (cpumask_test_cpu(cpu, node_to_cpumask_map[node])) {
+               cpumask_set_cpu(cpu, node_to_cpumask_map[node]);
        } else {
                printk(KERN_ERR "WARNING: cpu %lu not found in node %d\n",
                       cpu, node);
@@ -737,8 +762,9 @@ void __init dump_numa_cpu_topology(void)
                 * If we used a CPU iterator here we would miss printing
                 * the holes in the cpumap.
                 */
-               for (cpu = 0; cpu < NR_CPUS; cpu++) {
-                       if (cpu_isset(cpu, numa_cpumask_lookup_table[node])) {
+               for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
+                       if (cpumask_test_cpu(cpu,
+                                       node_to_cpumask_map[node])) {
                                if (count == 0)
                                        printk(" %u", cpu);
                                ++count;
@@ -750,7 +776,7 @@ void __init dump_numa_cpu_topology(void)
                }
 
                if (count > 1)
-                       printk("-%u", NR_CPUS - 1);
+                       printk("-%u", nr_cpu_ids - 1);
                printk("\n");
        }
 }
@@ -926,10 +952,6 @@ void __init do_init_bootmem(void)
        else
                dump_numa_memory_topology();
 
-       register_cpu_notifier(&ppc64_numa_nb);
-       cpu_numa_callback(&ppc64_numa_nb, CPU_UP_PREPARE,
-                         (void *)(unsigned long)boot_cpuid);
-
        for_each_online_node(nid) {
                unsigned long start_pfn, end_pfn;
                void *bootmem_vaddr;
@@ -983,6 +1005,16 @@ void __init do_init_bootmem(void)
        }
 
        init_bootmem_done = 1;
+
+       /*
+        * Now bootmem is initialised we can create the node to cpumask
+        * lookup tables and setup the cpu callback to populate them.
+        */
+       setup_node_to_cpumask_map();
+
+       register_cpu_notifier(&ppc64_numa_nb);
+       cpu_numa_callback(&ppc64_numa_nb, CPU_UP_PREPARE,
+                         (void *)(unsigned long)boot_cpuid);
 }
 
 void __init paging_init(void)