From: Anton Blanchard <anton@samba.org>
To: benh@kernel.crashing.org, rusty@rustcorp.com.au
Cc: linuxppc-dev@ozlabs.org
Subject: [patch 12/15] powerpc: cpumask: Convert NUMA code to new cpumask API
Date: Tue, 27 Apr 2010 11:32:43 +1000 [thread overview]
Message-ID: <20100427013432.657193481@samba.org> (raw)
In-Reply-To: 20100427013231.510168034@samba.org
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>
---
Index: linux-cpumask/arch/powerpc/include/asm/mmzone.h
===================================================================
--- linux-cpumask.orig/arch/powerpc/include/asm/mmzone.h 2010-04-12 09:17:47.847946437 +1000
+++ linux-cpumask/arch/powerpc/include/asm/mmzone.h 2010-04-22 13:03:26.335446079 +1000
@@ -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: linux-cpumask/arch/powerpc/mm/numa.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/mm/numa.c 2010-04-12 09:17:47.817946138 +1000
+++ linux-cpumask/arch/powerpc/mm/numa.c 2010-04-22 13:03:26.335446079 +1000
@@ -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(in
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
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)
Index: linux-cpumask/arch/powerpc/include/asm/topology.h
===================================================================
--- linux-cpumask.orig/arch/powerpc/include/asm/topology.h 2010-04-22 13:03:22.535446350 +1000
+++ linux-cpumask/arch/powerpc/include/asm/topology.h 2010-04-22 13:03:26.345446035 +1000
@@ -19,7 +19,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);
next prev parent reply other threads:[~2010-04-27 1:32 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-27 1:32 [patch 00/15] PowerPC cpumask patches Anton Blanchard
2010-04-27 1:32 ` [patch 01/15] powerpc: cpumask: Use cpu_online_mask Anton Blanchard
2010-04-27 1:32 ` [patch 02/15] powerpc: cpumask: Convert rtasd to new cpumask API Anton Blanchard
2010-04-27 1:32 ` [patch 03/15] powerpc: cpumask: Convert smp_cpus_done " Anton Blanchard
2010-04-28 2:09 ` Stephen Rothwell
2010-04-27 1:32 ` [patch 04/15] powerpc: cpumask: Convert fixup_irqs " Anton Blanchard
2010-04-27 1:32 ` [patch 05/15] powerpc: cpumask: Convert iseries SMP code " Anton Blanchard
2010-04-27 1:32 ` [patch 06/15] powerpc: cpumask: Convert pseries " Anton Blanchard
2010-04-27 1:32 ` [patch 07/15] powerpc: cpumask: Convert xics driver " Anton Blanchard
2010-04-27 1:32 ` [patch 08/15] powerpc: cpumask: Refactor /proc/cpuinfo code Anton Blanchard
2010-04-27 1:32 ` [patch 09/15] powerpc: cpumask: Convert /proc/cpuinfo to new cpumask API Anton Blanchard
2010-04-27 1:32 ` [patch 10/15] powerpc: cpumask: Dynamically allocate cpu_sibling_map and cpu_core_map cpumasks Anton Blanchard
2010-04-27 1:32 ` [patch 11/15] powerpc: cpumask: Convert hotplug-cpu code to new cpumask API Anton Blanchard
2010-04-27 1:32 ` Anton Blanchard [this message]
2010-04-27 1:32 ` [patch 13/15] powerpc: cpumask: Update some comments Anton Blanchard
2010-04-27 1:32 ` [patch 14/15] powerpc: cpumask: Convert mpic driver to new cpumask API Anton Blanchard
2010-04-27 1:32 ` [patch 15/15] powerpc: cpumask: Add DEBUG_PER_CPU_MAPS option Anton Blanchard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100427013432.657193481@samba.org \
--to=anton@samba.org \
--cc=benh@kernel.crashing.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=rusty@rustcorp.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).