Skip to content

Commit

Permalink
powerpc/cpumask: Convert NUMA code to new cpumask API
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Anton Blanchard authored and Benjamin Herrenschmidt committed May 6, 2010
1 parent 8729faa commit 25863de
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 15 deletions.
2 changes: 1 addition & 1 deletion arch/powerpc/include/asm/mmzone.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/include/asm/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
58 changes: 45 additions & 13 deletions arch/powerpc/mm/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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");
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 25863de

Please sign in to comment.