linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [patch 00/15] PowerPC cpumask patches
@ 2010-04-27  1:32 Anton Blanchard
  2010-04-27  1:32 ` [patch 01/15] powerpc: cpumask: Use cpu_online_mask Anton Blanchard
                   ` (14 more replies)
  0 siblings, 15 replies; 17+ messages in thread
From: Anton Blanchard @ 2010-04-27  1:32 UTC (permalink / raw)
  To: benh, rusty; +Cc: linuxppc-dev

This is a first attempt at converting PowerPC across to the new cpumask
API.  

I need to audit the GFP_ flags of alloc_cpumask_var. There are also a few
areas still to be done: cell, xmon, kexec, crashdump and the cputhreads code

Anton

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [patch 01/15] powerpc: cpumask: Use cpu_online_mask
  2010-04-27  1:32 [patch 00/15] PowerPC cpumask patches Anton Blanchard
@ 2010-04-27  1:32 ` Anton Blanchard
  2010-04-27  1:32 ` [patch 02/15] powerpc: cpumask: Convert rtasd to new cpumask API Anton Blanchard
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Anton Blanchard @ 2010-04-27  1:32 UTC (permalink / raw)
  To: benh, rusty; +Cc: linuxppc-dev

Change &cpu_online_map to cpu_online_mask.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Index: linux-cpumask/arch/powerpc/platforms/pasemi/cpufreq.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/platforms/pasemi/cpufreq.c	2010-04-08 19:46:04.459196015 +1000
+++ linux-cpumask/arch/powerpc/platforms/pasemi/cpufreq.c	2010-04-22 13:02:53.536695878 +1000
@@ -213,7 +213,7 @@ static int pas_cpufreq_cpu_init(struct c
 	pr_debug("current astate is at %d\n",cur_astate);
 
 	policy->cur = pas_freqs[cur_astate].frequency;
-	cpumask_copy(policy->cpus, &cpu_online_map);
+	cpumask_copy(policy->cpus, cpu_online_mask);
 
 	ppc_proc_freq = policy->cur * 1000ul;
 
Index: linux-cpumask/arch/powerpc/platforms/powermac/cpufreq_64.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/platforms/powermac/cpufreq_64.c	2010-04-08 19:46:04.479196466 +1000
+++ linux-cpumask/arch/powerpc/platforms/powermac/cpufreq_64.c	2010-04-22 13:02:53.546695890 +1000
@@ -362,7 +362,7 @@ static int g5_cpufreq_cpu_init(struct cp
 	/* secondary CPUs are tied to the primary one by the
 	 * cpufreq core if in the secondary policy we tell it that
 	 * it actually must be one policy together with all others. */
-	cpumask_copy(policy->cpus, &cpu_online_map);
+	cpumask_copy(policy->cpus, cpu_online_mask);
 	cpufreq_frequency_table_get_attr(g5_cpu_freqs, policy->cpu);
 
 	return cpufreq_frequency_table_cpuinfo(policy,

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [patch 02/15] powerpc: cpumask: Convert rtasd to new cpumask API
  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 ` Anton Blanchard
  2010-04-27  1:32 ` [patch 03/15] powerpc: cpumask: Convert smp_cpus_done " Anton Blanchard
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Anton Blanchard @ 2010-04-27  1:32 UTC (permalink / raw)
  To: benh, rusty; +Cc: linuxppc-dev

Use cpumask_first, cpumask_next in rtasd code.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Index: linux-cpumask/arch/powerpc/kernel/rtasd.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/kernel/rtasd.c	2010-04-08 19:46:04.419206665 +1000
+++ linux-cpumask/arch/powerpc/kernel/rtasd.c	2010-04-22 13:03:10.035445948 +1000
@@ -411,9 +411,9 @@ static void rtas_event_scan(struct work_
 
 	get_online_cpus();
 
-	cpu = next_cpu(smp_processor_id(), cpu_online_map);
-	if (cpu == NR_CPUS) {
-		cpu = first_cpu(cpu_online_map);
+	cpu = cpumask_next(smp_processor_id(), cpu_online_mask);
+        if (cpu >= nr_cpu_ids) {
+		cpu = cpumask_first(cpu_online_mask);
 
 		if (first_pass) {
 			first_pass = 0;
@@ -466,8 +466,8 @@ static void start_event_scan(void)
 	/* Retreive errors from nvram if any */
 	retreive_nvram_error_log();
 
-	schedule_delayed_work_on(first_cpu(cpu_online_map), &event_scan_work,
-				 event_scan_delay);
+	schedule_delayed_work_on(cpumask_first(cpu_online_mask),
+				 &event_scan_work, event_scan_delay);
 }
 
 static int __init rtas_init(void)

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [patch 03/15] powerpc: cpumask: Convert smp_cpus_done to new cpumask API
  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 ` Anton Blanchard
  2010-04-28  2:09   ` Stephen Rothwell
  2010-04-27  1:32 ` [patch 04/15] powerpc: cpumask: Convert fixup_irqs " Anton Blanchard
                   ` (11 subsequent siblings)
  14 siblings, 1 reply; 17+ messages in thread
From: Anton Blanchard @ 2010-04-27  1:32 UTC (permalink / raw)
  To: benh, rusty; +Cc: linuxppc-dev

Use the new cpumask_* functions and dynamically allocate the cpumask in
smp_cpus_done.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Index: linux-cpumask/arch/powerpc/kernel/smp.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/kernel/smp.c	2010-04-08 19:46:04.379196361 +1000
+++ linux-cpumask/arch/powerpc/kernel/smp.c	2010-04-22 13:03:13.025446124 +1000
@@ -554,19 +554,22 @@ int setup_profiling_timer(unsigned int m
 
 void __init smp_cpus_done(unsigned int max_cpus)
 {
-	cpumask_t old_mask;
+	cpumask_var_t old_mask;
 
 	/* We want the setup_cpu() here to be called from CPU 0, but our
 	 * init thread may have been "borrowed" by another CPU in the meantime
 	 * se we pin us down to CPU 0 for a short while
 	 */
-	old_mask = current->cpus_allowed;
-	set_cpus_allowed(current, cpumask_of_cpu(boot_cpuid));
-	
+	alloc_cpumask_var(&old_mask, GFP_NOWAIT);
+	cpumask_copy(old_mask, &current->cpus_allowed);
+	set_cpus_allowed_ptr(current, cpumask_of(boot_cpuid));
+
 	if (smp_ops && smp_ops->setup_cpu)
 		smp_ops->setup_cpu(boot_cpuid);
 
-	set_cpus_allowed(current, old_mask);
+	set_cpus_allowed_ptr(current, old_mask);
+
+	free_cpumask_var(old_mask);
 
 	snapshot_timebases();
 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [patch 04/15] powerpc: cpumask: Convert fixup_irqs to new cpumask API
  2010-04-27  1:32 [patch 00/15] PowerPC cpumask patches Anton Blanchard
                   ` (2 preceding siblings ...)
  2010-04-27  1:32 ` [patch 03/15] powerpc: cpumask: Convert smp_cpus_done " Anton Blanchard
@ 2010-04-27  1:32 ` Anton Blanchard
  2010-04-27  1:32 ` [patch 05/15] powerpc: cpumask: Convert iseries SMP code " Anton Blanchard
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Anton Blanchard @ 2010-04-27  1:32 UTC (permalink / raw)
  To: benh, rusty; +Cc: linuxppc-dev

Use new cpumask_* functions, and dynamically allocate cpumask in fixup_irqs.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Index: linux-cpumask/arch/powerpc/kernel/irq.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/kernel/irq.c	2010-04-08 19:46:04.269196650 +1000
+++ linux-cpumask/arch/powerpc/kernel/irq.c	2010-04-22 13:03:14.615446106 +1000
@@ -290,30 +290,33 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
-void fixup_irqs(cpumask_t map)
+void fixup_irqs(const struct cpumask *map)
 {
 	struct irq_desc *desc;
 	unsigned int irq;
 	static int warned;
+	cpumask_var_t mask;
 
-	for_each_irq(irq) {
-		cpumask_t mask;
+	alloc_cpumask_var(&mask, GFP_KERNEL);
 
+	for_each_irq(irq) {
 		desc = irq_to_desc(irq);
 		if (desc && desc->status & IRQ_PER_CPU)
 			continue;
 
-		cpumask_and(&mask, desc->affinity, &map);
-		if (any_online_cpu(mask) == NR_CPUS) {
+		cpumask_and(mask, desc->affinity, map);
+		if (cpumask_any(mask) >= nr_cpu_ids) {
 			printk("Breaking affinity for irq %i\n", irq);
-			mask = map;
+			cpumask_copy(mask, map);
 		}
 		if (desc->chip->set_affinity)
-			desc->chip->set_affinity(irq, &mask);
+			desc->chip->set_affinity(irq, mask);
 		else if (desc->action && !(warned++))
 			printk("Cannot set affinity for irq %i\n", irq);
 	}
 
+	free_cpumask_var(mask);
+
 	local_irq_enable();
 	mdelay(1);
 	local_irq_disable();
Index: linux-cpumask/arch/powerpc/kernel/smp.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/kernel/smp.c	2010-04-22 13:03:13.025446124 +1000
+++ linux-cpumask/arch/powerpc/kernel/smp.c	2010-04-22 13:03:14.615446106 +1000
@@ -313,7 +313,7 @@ int generic_cpu_disable(void)
 	set_cpu_online(cpu, false);
 #ifdef CONFIG_PPC64
 	vdso_data->processorCount--;
-	fixup_irqs(cpu_online_map);
+	fixup_irqs(cpu_online_mask);
 #endif
 	return 0;
 }
@@ -333,7 +333,7 @@ int generic_cpu_enable(unsigned int cpu)
 		cpu_relax();
 
 #ifdef CONFIG_PPC64
-	fixup_irqs(cpu_online_map);
+	fixup_irqs(cpu_online_mask);
 	/* counter the irq disable in fixup_irqs */
 	local_irq_enable();
 #endif
Index: linux-cpumask/arch/powerpc/include/asm/smp.h
===================================================================
--- linux-cpumask.orig/arch/powerpc/include/asm/smp.h	2010-04-08 19:46:04.299203515 +1000
+++ linux-cpumask/arch/powerpc/include/asm/smp.h	2010-04-22 13:03:14.635445670 +1000
@@ -40,7 +40,7 @@ extern void smp_message_recv(int);
 DECLARE_PER_CPU(unsigned int, cpu_pvr);
 
 #ifdef CONFIG_HOTPLUG_CPU
-extern void fixup_irqs(cpumask_t map);
+extern void fixup_irqs(const struct cpumask *map);
 int generic_cpu_disable(void);
 int generic_cpu_enable(unsigned int cpu);
 void generic_cpu_die(unsigned int cpu);

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [patch 05/15] powerpc: cpumask: Convert iseries SMP code to new cpumask API
  2010-04-27  1:32 [patch 00/15] PowerPC cpumask patches Anton Blanchard
                   ` (3 preceding siblings ...)
  2010-04-27  1:32 ` [patch 04/15] powerpc: cpumask: Convert fixup_irqs " Anton Blanchard
@ 2010-04-27  1:32 ` Anton Blanchard
  2010-04-27  1:32 ` [patch 06/15] powerpc: cpumask: Convert pseries " Anton Blanchard
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Anton Blanchard @ 2010-04-27  1:32 UTC (permalink / raw)
  To: benh, rusty; +Cc: linuxppc-dev

Use new cpumask functions in iseries SMP startup code.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Index: linux-cpumask/arch/powerpc/platforms/iseries/smp.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/platforms/iseries/smp.c	2010-04-08 19:46:04.129196495 +1000
+++ linux-cpumask/arch/powerpc/platforms/iseries/smp.c	2010-04-22 13:03:16.326695430 +1000
@@ -83,7 +83,7 @@ static void smp_iSeries_message_pass(int
 
 static int smp_iSeries_probe(void)
 {
-	return cpus_weight(cpu_possible_map);
+	return cpumask_weight(cpu_possible_mask);
 }
 
 static void smp_iSeries_kick_cpu(int nr)

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [patch 06/15] powerpc: cpumask: Convert pseries SMP code to new cpumask API
  2010-04-27  1:32 [patch 00/15] PowerPC cpumask patches Anton Blanchard
                   ` (4 preceding siblings ...)
  2010-04-27  1:32 ` [patch 05/15] powerpc: cpumask: Convert iseries SMP code " Anton Blanchard
@ 2010-04-27  1:32 ` Anton Blanchard
  2010-04-27  1:32 ` [patch 07/15] powerpc: cpumask: Convert xics driver " Anton Blanchard
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Anton Blanchard @ 2010-04-27  1:32 UTC (permalink / raw)
  To: benh, rusty; +Cc: linuxppc-dev

Use new cpumask functions in pseries SMP startup code.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Index: linux-cpumask/arch/powerpc/platforms/pseries/smp.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/platforms/pseries/smp.c	2010-04-08 19:46:04.089198328 +1000
+++ linux-cpumask/arch/powerpc/platforms/pseries/smp.c	2010-04-22 13:03:17.517946041 +1000
@@ -55,7 +55,7 @@
  * The Primary thread of each non-boot processor was started from the OF client
  * interface by prom_hold_cpus and is spinning on secondary_hold_spinloop.
  */
-static cpumask_t of_spin_map;
+static cpumask_var_t of_spin_mask;
 
 /**
  * smp_startup_cpu() - start the given cpu
@@ -76,7 +76,7 @@ static inline int __devinit smp_startup_
 	unsigned int pcpu;
 	int start_cpu;
 
-	if (cpu_isset(lcpu, of_spin_map))
+	if (cpumask_test_cpu(lcpu, of_spin_mask))
 		/* Already started by OF and sitting in spin loop */
 		return 1;
 
@@ -115,7 +115,7 @@ static void __devinit smp_xics_setup_cpu
 	if (firmware_has_feature(FW_FEATURE_SPLPAR))
 		vpa_init(cpu);
 
-	cpu_clear(cpu, of_spin_map);
+	cpumask_clear_cpu(cpu, of_spin_mask);
 	set_cpu_current_state(cpu, CPU_STATE_ONLINE);
 	set_default_offline_state(cpu);
 
@@ -186,17 +186,19 @@ static void __init smp_init_pseries(void
 
 	pr_debug(" -> smp_init_pSeries()\n");
 
+	alloc_bootmem_cpumask_var(&of_spin_mask);
+
 	/* Mark threads which are still spinning in hold loops. */
 	if (cpu_has_feature(CPU_FTR_SMT)) {
 		for_each_present_cpu(i) { 
 			if (cpu_thread_in_core(i) == 0)
-				cpu_set(i, of_spin_map);
+				cpumask_set_cpu(i, of_spin_mask);
 		}
 	} else {
-		of_spin_map = cpu_present_map;
+		cpumask_copy(of_spin_mask, cpu_present_mask);
 	}
 
-	cpu_clear(boot_cpuid, of_spin_map);
+	cpumask_clear_cpu(boot_cpuid, of_spin_mask);
 
 	/* Non-lpar has additional take/give timebase */
 	if (rtas_token("freeze-time-base") != RTAS_UNKNOWN_SERVICE) {

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [patch 07/15] powerpc: cpumask: Convert xics driver to new cpumask API
  2010-04-27  1:32 [patch 00/15] PowerPC cpumask patches Anton Blanchard
                   ` (5 preceding siblings ...)
  2010-04-27  1:32 ` [patch 06/15] powerpc: cpumask: Convert pseries " Anton Blanchard
@ 2010-04-27  1:32 ` Anton Blanchard
  2010-04-27  1:32 ` [patch 08/15] powerpc: cpumask: Refactor /proc/cpuinfo code Anton Blanchard
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Anton Blanchard @ 2010-04-27  1:32 UTC (permalink / raw)
  To: benh, rusty; +Cc: linuxppc-dev

Use the new cpumask API and add some comments to clarify how get_irq_server
works.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Index: linux-cpumask/arch/powerpc/platforms/pseries/xics.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/platforms/pseries/xics.c	2010-04-08 19:46:04.039197077 +1000
+++ linux-cpumask/arch/powerpc/platforms/pseries/xics.c	2010-04-22 13:03:18.825447113 +1000
@@ -163,29 +163,37 @@ static inline void lpar_qirr_info(int n_
 /* Interface to generic irq subsystem */
 
 #ifdef CONFIG_SMP
-static int get_irq_server(unsigned int virq, cpumask_t cpumask,
+/*
+ * For the moment we only implement delivery to all cpus or one cpu.
+ *
+ * If the requested affinity is cpu_all_mask, we set global affinity.
+ * If not we set it to the first cpu in the mask, even if multiple cpus
+ * are set. This is so things like irqbalance (which set core and package
+ * wide affinities) do the right thing.
+ */
+static int get_irq_server(unsigned int virq, const struct cpumask *cpumask,
 			  unsigned int strict_check)
 {
-	int server;
-	/* For the moment only implement delivery to all cpus or one cpu */
-	cpumask_t tmp = CPU_MASK_NONE;
 
 	if (!distribute_irqs)
 		return default_server;
 
-	if (!cpus_equal(cpumask, CPU_MASK_ALL)) {
-		cpus_and(tmp, cpu_online_map, cpumask);
-
-		server = first_cpu(tmp);
+	if (!cpumask_equal(cpumask, cpu_all_mask)) {
+		int server = cpumask_first_and(cpu_online_mask, cpumask);
 
-		if (server < NR_CPUS)
+		if (server < nr_cpu_ids)
 			return get_hard_smp_processor_id(server);
 
 		if (strict_check)
 			return -1;
 	}
 
-	if (cpus_equal(cpu_online_map, cpu_present_map))
+	/*
+	 * Workaround issue with some versions of JS20 firmware that
+	 * deliver interrupts to cpus which haven't been started. This
+	 * happens when using the maxcpus= boot option.
+	 */
+	if (cpumask_equal(cpu_online_mask, cpu_present_mask))
 		return default_distrib_server;
 
 	return default_server;
@@ -207,7 +215,7 @@ static void xics_unmask_irq(unsigned int
 	if (irq == XICS_IPI || irq == XICS_IRQ_SPURIOUS)
 		return;
 
-	server = get_irq_server(virq, *(irq_to_desc(virq)->affinity), 0);
+	server = get_irq_server(virq, irq_to_desc(virq)->affinity, 0);
 
 	call_status = rtas_call(ibm_set_xive, 3, 1, NULL, irq, server,
 				DEFAULT_PRIORITY);
@@ -398,11 +406,7 @@ static int xics_set_affinity(unsigned in
 		return -1;
 	}
 
-	/*
-	 * For the moment only implement delivery to all cpus or one cpu.
-	 * Get current irq_server for the given irq
-	 */
-	irq_server = get_irq_server(virq, *cpumask, 1);
+	irq_server = get_irq_server(virq, cpumask, 1);
 	if (irq_server == -1) {
 		char cpulist[128];
 		cpumask_scnprintf(cpulist, sizeof(cpulist), cpumask);
@@ -611,7 +615,7 @@ int __init smp_xics_probe(void)
 {
 	xics_request_ipi();
 
-	return cpus_weight(cpu_possible_map);
+	return cpumask_weight(cpu_possible_mask);
 }
 
 #endif /* CONFIG_SMP */

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [patch 08/15] powerpc: cpumask: Refactor /proc/cpuinfo code
  2010-04-27  1:32 [patch 00/15] PowerPC cpumask patches Anton Blanchard
                   ` (6 preceding siblings ...)
  2010-04-27  1:32 ` [patch 07/15] powerpc: cpumask: Convert xics driver " Anton Blanchard
@ 2010-04-27  1:32 ` Anton Blanchard
  2010-04-27  1:32 ` [patch 09/15] powerpc: cpumask: Convert /proc/cpuinfo to new cpumask API Anton Blanchard
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Anton Blanchard @ 2010-04-27  1:32 UTC (permalink / raw)
  To: benh, rusty; +Cc: linuxppc-dev

This separates the per cpu output from the summary output at the end of the
file, making it easier to convert to the new cpumask API in a subsequent
patch.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Index: linux-cpumask/arch/powerpc/kernel/setup-common.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/kernel/setup-common.c	2010-04-08 19:46:03.999199713 +1000
+++ linux-cpumask/arch/powerpc/kernel/setup-common.c	2010-04-22 13:03:19.866696740 +1000
@@ -161,43 +161,47 @@ extern u32 cpu_temp_both(unsigned long c
 DEFINE_PER_CPU(unsigned int, cpu_pvr);
 #endif
 
-static int show_cpuinfo(struct seq_file *m, void *v)
+static void show_cpuinfo_summary(struct seq_file *m)
 {
-	unsigned long cpu_id = (unsigned long)v - 1;
-	unsigned int pvr;
-	unsigned short maj;
-	unsigned short min;
-
-	if (cpu_id == NR_CPUS) {
-		struct device_node *root;
-		const char *model = NULL;
+	struct device_node *root;
+	const char *model = NULL;
 #if defined(CONFIG_SMP) && defined(CONFIG_PPC32)
-		unsigned long bogosum = 0;
-		int i;
-		for_each_online_cpu(i)
-			bogosum += loops_per_jiffy;
-		seq_printf(m, "total bogomips\t: %lu.%02lu\n",
-			   bogosum/(500000/HZ), bogosum/(5000/HZ) % 100);
+	unsigned long bogosum = 0;
+	int i;
+	for_each_online_cpu(i)
+		bogosum += loops_per_jiffy;
+	seq_printf(m, "total bogomips\t: %lu.%02lu\n",
+		   bogosum/(500000/HZ), bogosum/(5000/HZ) % 100);
 #endif /* CONFIG_SMP && CONFIG_PPC32 */
-		seq_printf(m, "timebase\t: %lu\n", ppc_tb_freq);
-		if (ppc_md.name)
-			seq_printf(m, "platform\t: %s\n", ppc_md.name);
-		root = of_find_node_by_path("/");
-		if (root)
-			model = of_get_property(root, "model", NULL);
-		if (model)
-			seq_printf(m, "model\t\t: %s\n", model);
-		of_node_put(root);
+	seq_printf(m, "timebase\t: %lu\n", ppc_tb_freq);
+	if (ppc_md.name)
+		seq_printf(m, "platform\t: %s\n", ppc_md.name);
+	root = of_find_node_by_path("/");
+	if (root)
+		model = of_get_property(root, "model", NULL);
+	if (model)
+		seq_printf(m, "model\t\t: %s\n", model);
+	of_node_put(root);
 
-		if (ppc_md.show_cpuinfo != NULL)
-			ppc_md.show_cpuinfo(m);
+	if (ppc_md.show_cpuinfo != NULL)
+		ppc_md.show_cpuinfo(m);
 
 #ifdef CONFIG_PPC32
-		/* Display the amount of memory */
-		seq_printf(m, "Memory\t\t: %d MB\n",
-			   (unsigned int)(total_memory / (1024 * 1024)));
+	/* Display the amount of memory */
+	seq_printf(m, "Memory\t\t: %d MB\n",
+		   (unsigned int)(total_memory / (1024 * 1024)));
 #endif
+}
 
+static int show_cpuinfo(struct seq_file *m, void *v)
+{
+	unsigned long cpu_id = (unsigned long)v - 1;
+	unsigned int pvr;
+	unsigned short maj;
+	unsigned short min;
+
+	if (cpu_id == NR_CPUS) {
+		show_cpuinfo_summary(m);
 		return 0;
 	}
 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [patch 09/15] powerpc: cpumask: Convert /proc/cpuinfo to new cpumask API
  2010-04-27  1:32 [patch 00/15] PowerPC cpumask patches Anton Blanchard
                   ` (7 preceding siblings ...)
  2010-04-27  1:32 ` [patch 08/15] powerpc: cpumask: Refactor /proc/cpuinfo code Anton Blanchard
@ 2010-04-27  1:32 ` Anton Blanchard
  2010-04-27  1:32 ` [patch 10/15] powerpc: cpumask: Dynamically allocate cpu_sibling_map and cpu_core_map cpumasks Anton Blanchard
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Anton Blanchard @ 2010-04-27  1:32 UTC (permalink / raw)
  To: benh, rusty; +Cc: linuxppc-dev

Use new cpumask API in /proc/cpuinfo code.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Index: linux-cpumask/arch/powerpc/kernel/setup-common.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/kernel/setup-common.c	2010-04-22 13:03:19.866696740 +1000
+++ linux-cpumask/arch/powerpc/kernel/setup-common.c	2010-04-22 13:03:21.075446071 +1000
@@ -200,11 +200,6 @@ static int show_cpuinfo(struct seq_file 
 	unsigned short maj;
 	unsigned short min;
 
-	if (cpu_id == NR_CPUS) {
-		show_cpuinfo_summary(m);
-		return 0;
-	}
-
 	/* We only show online cpus: disable preempt (overzealous, I
 	 * knew) to prevent cpu going down. */
 	preempt_disable();
@@ -312,19 +307,28 @@ static int show_cpuinfo(struct seq_file 
 #endif
 
 	preempt_enable();
+
+	/* If this is the last cpu, print the summary */
+	if (cpumask_next(cpu_id, cpu_online_mask) >= nr_cpu_ids)
+		show_cpuinfo_summary(m);
+
 	return 0;
 }
 
 static void *c_start(struct seq_file *m, loff_t *pos)
 {
-	unsigned long i = *pos;
-
-	return i <= NR_CPUS ? (void *)(i + 1) : NULL;
+	if (*pos == 0)	/* just in case, cpu 0 is not the first */
+		*pos = cpumask_first(cpu_online_mask);
+	else
+		*pos = cpumask_next(*pos - 1, cpu_online_mask);
+	if ((*pos) < nr_cpu_ids)
+		return (void *)(*pos + 1);
+	return NULL;
 }
 
 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
 {
-	++*pos;
+	(*pos)++;
 	return c_start(m, pos);
 }
 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [patch 10/15] powerpc: cpumask: Dynamically allocate cpu_sibling_map and cpu_core_map cpumasks
  2010-04-27  1:32 [patch 00/15] PowerPC cpumask patches Anton Blanchard
                   ` (8 preceding siblings ...)
  2010-04-27  1:32 ` [patch 09/15] powerpc: cpumask: Convert /proc/cpuinfo to new cpumask API Anton Blanchard
@ 2010-04-27  1:32 ` Anton Blanchard
  2010-04-27  1:32 ` [patch 11/15] powerpc: cpumask: Convert hotplug-cpu code to new cpumask API Anton Blanchard
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Anton Blanchard @ 2010-04-27  1:32 UTC (permalink / raw)
  To: benh, rusty; +Cc: linuxppc-dev

Dynamically allocate cpu_sibling_map and cpu_core_map cpumasks.

We don't need to set_cpu_online() the boot cpu in smp_prepare_boot_cpu,
init/main.c does it for us.

We also postpone setting of the boot cpu in cpu_sibling_map and cpu_core_map
until when the memory allocator is available (smp_prepare_cpus), similar
to x86.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Index: linux-cpumask/arch/powerpc/include/asm/smp.h
===================================================================
--- linux-cpumask.orig/arch/powerpc/include/asm/smp.h	2010-04-22 13:03:14.635445670 +1000
+++ linux-cpumask/arch/powerpc/include/asm/smp.h	2010-04-22 13:03:22.525445945 +1000
@@ -68,8 +68,19 @@ static inline void set_hard_smp_processo
 }
 #endif
 
-DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
-DECLARE_PER_CPU(cpumask_t, cpu_core_map);
+DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_map);
+DECLARE_PER_CPU(cpumask_var_t, cpu_core_map);
+
+static inline struct cpumask *cpu_sibling_mask(int cpu)
+{
+	return per_cpu(cpu_sibling_map, cpu);
+}
+
+static inline struct cpumask *cpu_core_mask(int cpu)
+{
+	return per_cpu(cpu_core_map, cpu);
+}
+
 extern int cpu_to_core_id(int cpu);
 
 /* Since OpenPIC has only 4 IPIs, we use slightly different message numbers.
@@ -93,7 +104,6 @@ void smp_init_pSeries(void);
 void smp_init_cell(void);
 void smp_init_celleb(void);
 void smp_setup_cpu_maps(void);
-void smp_setup_cpu_sibling_map(void);
 
 extern int __cpu_disable(void);
 extern void __cpu_die(unsigned int cpu);
Index: linux-cpumask/arch/powerpc/include/asm/topology.h
===================================================================
--- linux-cpumask.orig/arch/powerpc/include/asm/topology.h	2010-04-12 09:17:47.827945841 +1000
+++ linux-cpumask/arch/powerpc/include/asm/topology.h	2010-04-22 13:03:22.535446350 +1000
@@ -102,8 +102,8 @@ static inline void sysfs_remove_device_f
 #ifdef CONFIG_PPC64
 #include <asm/smp.h>
 
-#define topology_thread_cpumask(cpu)	(&per_cpu(cpu_sibling_map, cpu))
-#define topology_core_cpumask(cpu)	(&per_cpu(cpu_core_map, cpu))
+#define topology_thread_cpumask(cpu)	(per_cpu(cpu_sibling_map, cpu))
+#define topology_core_cpumask(cpu)	(per_cpu(cpu_core_map, cpu))
 #define topology_core_id(cpu)		(cpu_to_core_id(cpu))
 #endif
 #endif
Index: linux-cpumask/arch/powerpc/kernel/smp.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/kernel/smp.c	2010-04-22 13:03:14.615446106 +1000
+++ linux-cpumask/arch/powerpc/kernel/smp.c	2010-04-22 13:03:22.545446024 +1000
@@ -59,8 +59,8 @@
 
 struct thread_info *secondary_ti;
 
-DEFINE_PER_CPU(cpumask_t, cpu_sibling_map) = CPU_MASK_NONE;
-DEFINE_PER_CPU(cpumask_t, cpu_core_map) = CPU_MASK_NONE;
+DEFINE_PER_CPU(cpumask_var_t, cpu_sibling_map);
+DEFINE_PER_CPU(cpumask_var_t, cpu_core_map);
 
 EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
 EXPORT_PER_CPU_SYMBOL(cpu_core_map);
@@ -271,6 +271,16 @@ void __init smp_prepare_cpus(unsigned in
 	smp_store_cpu_info(boot_cpuid);
 	cpu_callin_map[boot_cpuid] = 1;
 
+	for_each_possible_cpu(cpu) {
+		zalloc_cpumask_var_node(&per_cpu(cpu_sibling_map, cpu),
+					GFP_KERNEL, cpu_to_node(cpu));
+		zalloc_cpumask_var_node(&per_cpu(cpu_core_map, cpu),
+					GFP_KERNEL, cpu_to_node(cpu));
+	}
+
+	cpumask_set_cpu(boot_cpuid, cpu_sibling_mask(boot_cpuid));
+	cpumask_set_cpu(boot_cpuid, cpu_core_mask(boot_cpuid));
+
 	if (smp_ops)
 		if (smp_ops->probe)
 			max_cpus = smp_ops->probe();
@@ -289,10 +299,6 @@ void __init smp_prepare_cpus(unsigned in
 void __devinit smp_prepare_boot_cpu(void)
 {
 	BUG_ON(smp_processor_id() != boot_cpuid);
-
-	set_cpu_online(boot_cpuid, true);
-	cpu_set(boot_cpuid, per_cpu(cpu_sibling_map, boot_cpuid));
-	cpu_set(boot_cpuid, per_cpu(cpu_core_map, boot_cpuid));
 #ifdef CONFIG_PPC64
 	paca[boot_cpuid].__current = current;
 #endif
@@ -517,15 +523,15 @@ int __devinit start_secondary(void *unus
 	for (i = 0; i < threads_per_core; i++) {
 		if (cpu_is_offline(base + i))
 			continue;
-		cpu_set(cpu, per_cpu(cpu_sibling_map, base + i));
-		cpu_set(base + i, per_cpu(cpu_sibling_map, cpu));
+		cpumask_set_cpu(cpu, cpu_sibling_mask(base + i));
+		cpumask_set_cpu(base + i, cpu_sibling_mask(cpu));
 
 		/* cpu_core_map should be a superset of
 		 * cpu_sibling_map even if we don't have cache
 		 * information, so update the former here, too.
 		 */
-		cpu_set(cpu, per_cpu(cpu_core_map, base +i));
-		cpu_set(base + i, per_cpu(cpu_core_map, cpu));
+		cpumask_set_cpu(cpu, cpu_core_mask(base + i));
+		cpumask_set_cpu(base + i, cpu_core_mask(cpu));
 	}
 	l2_cache = cpu_to_l2cache(cpu);
 	for_each_online_cpu(i) {
@@ -533,8 +539,8 @@ int __devinit start_secondary(void *unus
 		if (!np)
 			continue;
 		if (np == l2_cache) {
-			cpu_set(cpu, per_cpu(cpu_core_map, i));
-			cpu_set(i, per_cpu(cpu_core_map, cpu));
+			cpumask_set_cpu(cpu, cpu_core_mask(i));
+			cpumask_set_cpu(i, cpu_core_mask(cpu));
 		}
 		of_node_put(np);
 	}
@@ -594,10 +600,10 @@ int __cpu_disable(void)
 	/* Update sibling maps */
 	base = cpu_first_thread_in_core(cpu);
 	for (i = 0; i < threads_per_core; i++) {
-		cpu_clear(cpu, per_cpu(cpu_sibling_map, base + i));
-		cpu_clear(base + i, per_cpu(cpu_sibling_map, cpu));
-		cpu_clear(cpu, per_cpu(cpu_core_map, base +i));
-		cpu_clear(base + i, per_cpu(cpu_core_map, cpu));
+		cpumask_clear_cpu(cpu, cpu_sibling_mask(base + i));
+		cpumask_clear_cpu(base + i, cpu_sibling_mask(cpu));
+		cpumask_clear_cpu(cpu, cpu_core_mask(base + i));
+		cpumask_clear_cpu(base + i, cpu_core_mask(cpu));
 	}
 
 	l2_cache = cpu_to_l2cache(cpu);
@@ -606,8 +612,8 @@ int __cpu_disable(void)
 		if (!np)
 			continue;
 		if (np == l2_cache) {
-			cpu_clear(cpu, per_cpu(cpu_core_map, i));
-			cpu_clear(i, per_cpu(cpu_core_map, cpu));
+			cpumask_clear_cpu(cpu, cpu_core_mask(i));
+			cpumask_clear_cpu(i, cpu_core_mask(cpu));
 		}
 		of_node_put(np);
 	}
Index: linux-cpumask/arch/powerpc/platforms/cell/cbe_cpufreq.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/platforms/cell/cbe_cpufreq.c	2010-04-08 19:46:03.749196323 +1000
+++ linux-cpumask/arch/powerpc/platforms/cell/cbe_cpufreq.c	2010-04-22 13:03:22.545446024 +1000
@@ -118,7 +118,7 @@ static int cbe_cpufreq_cpu_init(struct c
 	policy->cur = cbe_freqs[cur_pmode].frequency;
 
 #ifdef CONFIG_SMP
-	cpumask_copy(policy->cpus, &per_cpu(cpu_sibling_map, policy->cpu));
+	cpumask_copy(policy->cpus, cpu_sibling_mask(policy->cpu));
 #endif
 
 	cpufreq_frequency_table_get_attr(cbe_freqs, policy->cpu);

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [patch 11/15] powerpc: cpumask: Convert hotplug-cpu code to new cpumask API
  2010-04-27  1:32 [patch 00/15] PowerPC cpumask patches Anton Blanchard
                   ` (9 preceding siblings ...)
  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 ` Anton Blanchard
  2010-04-27  1:32 ` [patch 12/15] powerpc: cpumask: Convert NUMA " Anton Blanchard
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Anton Blanchard @ 2010-04-27  1:32 UTC (permalink / raw)
  To: benh, rusty; +Cc: linuxppc-dev

Convert hotplug-cpu code to new cpumask API.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Index: linux-cpumask/arch/powerpc/platforms/pseries/hotplug-cpu.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/platforms/pseries/hotplug-cpu.c	2010-04-08 19:46:03.437946780 +1000
+++ linux-cpumask/arch/powerpc/platforms/pseries/hotplug-cpu.c	2010-04-22 13:03:25.075445756 +1000
@@ -187,7 +187,7 @@ static int pseries_cpu_disable(void)
 
 	/*fix boot_cpuid here*/
 	if (cpu == boot_cpuid)
-		boot_cpuid = any_online_cpu(cpu_online_map);
+		boot_cpuid = cpumask_any(cpu_online_mask);
 
 	/* FIXME: abstract this to not be platform specific later on */
 	xics_migrate_irqs_away();
@@ -254,7 +254,7 @@ static void pseries_cpu_die(unsigned int
 static int pseries_add_processor(struct device_node *np)
 {
 	unsigned int cpu;
-	cpumask_t candidate_map, tmp = CPU_MASK_NONE;
+	cpumask_var_t candidate_mask, tmp;
 	int err = -ENOSPC, len, nthreads, i;
 	const u32 *intserv;
 
@@ -262,48 +262,53 @@ static int pseries_add_processor(struct 
 	if (!intserv)
 		return 0;
 
+	zalloc_cpumask_var(&candidate_mask, GFP_KERNEL);
+	zalloc_cpumask_var(&tmp, GFP_KERNEL);
+
 	nthreads = len / sizeof(u32);
 	for (i = 0; i < nthreads; i++)
-		cpu_set(i, tmp);
+		cpumask_set_cpu(i, tmp);
 
 	cpu_maps_update_begin();
 
-	BUG_ON(!cpus_subset(cpu_present_map, cpu_possible_map));
+	BUG_ON(!cpumask_subset(cpu_present_mask, cpu_possible_mask));
 
 	/* Get a bitmap of unoccupied slots. */
-	cpus_xor(candidate_map, cpu_possible_map, cpu_present_map);
-	if (cpus_empty(candidate_map)) {
+	cpumask_xor(candidate_mask, cpu_possible_mask, cpu_present_mask);
+	if (cpumask_empty(candidate_mask)) {
 		/* If we get here, it most likely means that NR_CPUS is
 		 * less than the partition's max processors setting.
 		 */
 		printk(KERN_ERR "Cannot add cpu %s; this system configuration"
 		       " supports %d logical cpus.\n", np->full_name,
-		       cpus_weight(cpu_possible_map));
+		       cpumask_weight(cpu_possible_mask));
 		goto out_unlock;
 	}
 
-	while (!cpus_empty(tmp))
-		if (cpus_subset(tmp, candidate_map))
+	while (!cpumask_empty(tmp))
+		if (cpumask_subset(tmp, candidate_mask))
 			/* Found a range where we can insert the new cpu(s) */
 			break;
 		else
-			cpus_shift_left(tmp, tmp, nthreads);
+			cpumask_shift_left(tmp, tmp, nthreads);
 
-	if (cpus_empty(tmp)) {
+	if (cpumask_empty(tmp)) {
 		printk(KERN_ERR "Unable to find space in cpu_present_map for"
 		       " processor %s with %d thread(s)\n", np->name,
 		       nthreads);
 		goto out_unlock;
 	}
 
-	for_each_cpu_mask(cpu, tmp) {
-		BUG_ON(cpu_isset(cpu, cpu_present_map));
+	for_each_cpu(cpu, tmp) {
+		BUG_ON(cpumask_test_cpu(cpu, cpu_present_mask));
 		set_cpu_present(cpu, true);
 		set_hard_smp_processor_id(cpu, *intserv++);
 	}
 	err = 0;
 out_unlock:
 	cpu_maps_update_done();
+	free_cpumask_var(candidate_mask);
+	free_cpumask_var(tmp);
 	return err;
 }
 
@@ -334,7 +339,7 @@ static void pseries_remove_processor(str
 			set_hard_smp_processor_id(cpu, -1);
 			break;
 		}
-		if (cpu == NR_CPUS)
+		if (cpu >= nr_cpu_ids)
 			printk(KERN_WARNING "Could not find cpu to remove "
 			       "with physical id 0x%x\n", intserv[i]);
 	}

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [patch 12/15] powerpc: cpumask: Convert NUMA code to new cpumask API
  2010-04-27  1:32 [patch 00/15] PowerPC cpumask patches Anton Blanchard
                   ` (10 preceding siblings ...)
  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
  2010-04-27  1:32 ` [patch 13/15] powerpc: cpumask: Update some comments Anton Blanchard
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Anton Blanchard @ 2010-04-27  1:32 UTC (permalink / raw)
  To: benh, rusty; +Cc: linuxppc-dev

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);
 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [patch 13/15] powerpc: cpumask: Update some comments
  2010-04-27  1:32 [patch 00/15] PowerPC cpumask patches Anton Blanchard
                   ` (11 preceding siblings ...)
  2010-04-27  1:32 ` [patch 12/15] powerpc: cpumask: Convert NUMA " Anton Blanchard
@ 2010-04-27  1:32 ` 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
  14 siblings, 0 replies; 17+ messages in thread
From: Anton Blanchard @ 2010-04-27  1:32 UTC (permalink / raw)
  To: benh, rusty; +Cc: linuxppc-dev

Since the *_map cpumask variants are deprecated, change the comments to
instead refer to *_mask.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Index: linux-cpumask/arch/powerpc/kernel/setup-common.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/kernel/setup-common.c	2010-04-22 13:19:24.536696551 +1000
+++ linux-cpumask/arch/powerpc/kernel/setup-common.c	2010-04-22 13:25:56.655446062 +1000
@@ -394,14 +394,14 @@ static void __init cpu_init_thread_core_
 
 /**
  * setup_cpu_maps - initialize the following cpu maps:
- *                  cpu_possible_map
- *                  cpu_present_map
+ *                  cpu_possible_mask
+ *                  cpu_present_mask
  *
  * Having the possible map set up early allows us to restrict allocations
  * of things like irqstacks to num_possible_cpus() rather than NR_CPUS.
  *
  * We do not initialize the online map here; cpus set their own bits in
- * cpu_online_map as they come up.
+ * cpu_online_mask as they come up.
  *
  * This function is valid only for Open Firmware systems.  finish_device_tree
  * must be called before using this.
Index: linux-cpumask/arch/powerpc/kernel/smp.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/kernel/smp.c	2010-04-22 13:03:22.545446024 +1000
+++ linux-cpumask/arch/powerpc/kernel/smp.c	2010-04-22 13:25:56.655446062 +1000
@@ -468,7 +468,7 @@ out:
 	return id;
 }
 
-/* Must be called when no change can occur to cpu_present_map,
+/* Must be called when no change can occur to cpu_present_mask,
  * i.e. during cpu online or offline.
  */
 static struct device_node *cpu_to_l2cache(int cpu)
Index: linux-cpumask/arch/powerpc/platforms/powermac/setup.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/platforms/powermac/setup.c	2010-04-07 09:18:12.016695779 +1000
+++ linux-cpumask/arch/powerpc/platforms/powermac/setup.c	2010-04-22 13:25:56.665445906 +1000
@@ -480,7 +480,7 @@ static void __init pmac_init_early(void)
 #endif
 
 	/* SMP Init has to be done early as we need to patch up
-	 * cpu_possible_map before interrupt stacks are allocated
+	 * cpu_possible_mask before interrupt stacks are allocated
 	 * or kaboom...
 	 */
 #ifdef CONFIG_SMP
Index: linux-cpumask/arch/powerpc/platforms/powermac/smp.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/platforms/powermac/smp.c	2010-02-27 09:45:02.816822011 +1100
+++ linux-cpumask/arch/powerpc/platforms/powermac/smp.c	2010-04-22 13:26:27.485445638 +1000
@@ -315,7 +315,7 @@ static int __init smp_psurge_probe(void)
 	/* This is necessary because OF doesn't know about the
 	 * secondary cpu(s), and thus there aren't nodes in the
 	 * device tree for them, and smp_setup_cpu_maps hasn't
-	 * set their bits in cpu_present_map.
+	 * set their bits in cpu_present_mask.
 	 */
 	if (ncpus > NR_CPUS)
 		ncpus = NR_CPUS;
@@ -944,7 +944,7 @@ void __init pmac_setup_smp(void)
 	}
 #ifdef CONFIG_PPC32
 	else {
-		/* We have to set bits in cpu_possible_map here since the
+		/* We have to set bits in cpu_possible_mask here since the
 		 * secondary CPU(s) aren't in the device tree. Various
 		 * things won't be initialized for CPUs not in the possible
 		 * map, so we really need to fix it up here.
Index: linux-cpumask/arch/powerpc/platforms/pseries/hotplug-cpu.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/platforms/pseries/hotplug-cpu.c	2010-04-22 13:27:02.755445663 +1000
+++ linux-cpumask/arch/powerpc/platforms/pseries/hotplug-cpu.c	2010-04-22 13:27:13.025733412 +1000
@@ -245,7 +245,7 @@ static void pseries_cpu_die(unsigned int
 }
 
 /*
- * Update cpu_present_map and paca(s) for a new cpu node.  The wrinkle
+ * Update cpu_present_mask and paca(s) for a new cpu node.  The wrinkle
  * here is that a cpu device node may represent up to two logical cpus
  * in the SMT case.  We must honor the assumption in other code that
  * the logical ids for sibling SMT threads x and y are adjacent, such
@@ -293,7 +293,7 @@ static int pseries_add_processor(struct 
 			cpumask_shift_left(tmp, tmp, nthreads);
 
 	if (cpumask_empty(tmp)) {
-		printk(KERN_ERR "Unable to find space in cpu_present_map for"
+		printk(KERN_ERR "Unable to find space in cpu_present_mask for"
 		       " processor %s with %d thread(s)\n", np->name,
 		       nthreads);
 		goto out_unlock;

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [patch 14/15] powerpc: cpumask: Convert mpic driver to new cpumask API
  2010-04-27  1:32 [patch 00/15] PowerPC cpumask patches Anton Blanchard
                   ` (12 preceding siblings ...)
  2010-04-27  1:32 ` [patch 13/15] powerpc: cpumask: Update some comments Anton Blanchard
@ 2010-04-27  1:32 ` Anton Blanchard
  2010-04-27  1:32 ` [patch 15/15] powerpc: cpumask: Add DEBUG_PER_CPU_MAPS option Anton Blanchard
  14 siblings, 0 replies; 17+ messages in thread
From: Anton Blanchard @ 2010-04-27  1:32 UTC (permalink / raw)
  To: benh, rusty; +Cc: linuxppc-dev

Convert to the new cpumask API.

irq_choose_cpu can be simplified by using cpumask_next and cpumask_first.

smp_mpic_message_pass was doing open coded cpumask manipulation and passing an
int for a cpumask into mpic_send_ipi. Since mpic_send_ipi is only used
locally, make it static and convert it to take a cpumask. This allows us
to clean up the mess in smp_mpic_message_pass.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Index: linux-cpumask/arch/powerpc/sysdev/mpic.c
===================================================================
--- linux-cpumask.orig/arch/powerpc/sysdev/mpic.c	2010-04-22 14:52:08.876696006 +1000
+++ linux-cpumask/arch/powerpc/sysdev/mpic.c	2010-04-22 14:58:13.495445579 +1000
@@ -568,12 +568,12 @@ static void __init mpic_scan_ht_pics(str
 #endif /* CONFIG_MPIC_U3_HT_IRQS */
 
 #ifdef CONFIG_SMP
-static int irq_choose_cpu(const cpumask_t *mask)
+static int irq_choose_cpu(const struct cpumask *mask)
 {
 	int cpuid;
 
 	if (cpumask_equal(mask, cpu_all_mask)) {
-		static int irq_rover;
+		static int irq_rover = 0;
 		static DEFINE_RAW_SPINLOCK(irq_rover_lock);
 		unsigned long flags;
 
@@ -581,15 +581,11 @@ static int irq_choose_cpu(const cpumask_
 	do_round_robin:
 		raw_spin_lock_irqsave(&irq_rover_lock, flags);
 
-		while (!cpu_online(irq_rover)) {
-			if (++irq_rover >= NR_CPUS)
-				irq_rover = 0;
-		}
+		irq_rover = cpumask_next(irq_rover, cpu_online_mask);
+		if (irq_rover >= nr_cpu_ids)
+			irq_rover = cpumask_first(cpu_online_mask);
+
 		cpuid = irq_rover;
-		do {
-			if (++irq_rover >= NR_CPUS)
-				irq_rover = 0;
-		} while (!cpu_online(irq_rover));
 
 		raw_spin_unlock_irqrestore(&irq_rover_lock, flags);
 	} else {
@@ -601,7 +597,7 @@ static int irq_choose_cpu(const cpumask_
 	return get_hard_smp_processor_id(cpuid);
 }
 #else
-static int irq_choose_cpu(const cpumask_t *mask)
+static int irq_choose_cpu(const struct cpumask *mask)
 {
 	return hard_smp_processor_id();
 }
@@ -814,12 +810,16 @@ int mpic_set_affinity(unsigned int irq, 
 
 		mpic_irq_write(src, MPIC_INFO(IRQ_DESTINATION), 1 << cpuid);
 	} else {
-		cpumask_t tmp;
+		cpumask_var_t tmp;
+
+		alloc_cpumask_var(&tmp, GFP_KERNEL);
 
-		cpumask_and(&tmp, cpumask, cpu_online_mask);
+		cpumask_and(tmp, cpumask, cpu_online_mask);
 
 		mpic_irq_write(src, MPIC_INFO(IRQ_DESTINATION),
-			       mpic_physmask(cpus_addr(tmp)[0]));
+			       mpic_physmask(cpumask_bits(tmp)[0]));
+
+		free_cpumask_var(tmp);
 	}
 
 	return 0;
@@ -1479,7 +1479,7 @@ void mpic_teardown_this_cpu(int secondar
 }
 
 
-void mpic_send_ipi(unsigned int ipi_no, unsigned int cpu_mask)
+static void mpic_send_ipi(unsigned int ipi_no, const struct cpumask *cpu_mask)
 {
 	struct mpic *mpic = mpic_primary;
 
@@ -1491,7 +1491,7 @@ void mpic_send_ipi(unsigned int ipi_no, 
 
 	mpic_cpu_write(MPIC_INFO(CPU_IPI_DISPATCH_0) +
 		       ipi_no * MPIC_INFO(CPU_IPI_DISPATCH_STRIDE),
-		       mpic_physmask(cpu_mask & cpus_addr(cpu_online_map)[0]));
+		       mpic_physmask(cpumask_bits(cpu_mask)[0]));
 }
 
 static unsigned int _mpic_get_one_irq(struct mpic *mpic, int reg)
@@ -1591,6 +1591,8 @@ void mpic_request_ipis(void)
 
 void smp_mpic_message_pass(int target, int msg)
 {
+	cpumask_var_t tmp;
+
 	/* make sure we're sending something that translates to an IPI */
 	if ((unsigned int)msg > 3) {
 		printk("SMP %d: smp_message_pass: unknown msg %d\n",
@@ -1599,13 +1601,17 @@ void smp_mpic_message_pass(int target, i
 	}
 	switch (target) {
 	case MSG_ALL:
-		mpic_send_ipi(msg, 0xffffffff);
+		mpic_send_ipi(msg, cpu_online_mask);
 		break;
 	case MSG_ALL_BUT_SELF:
-		mpic_send_ipi(msg, 0xffffffff & ~(1 << smp_processor_id()));
+		alloc_cpumask_var(&tmp, GFP_NOWAIT);
+		cpumask_andnot(tmp, cpu_online_mask,
+			       cpumask_of(smp_processor_id()));
+		mpic_send_ipi(msg, tmp);
+		free_cpumask_var(tmp);
 		break;
 	default:
-		mpic_send_ipi(msg, 1 << target);
+		mpic_send_ipi(msg, cpumask_of(target));
 		break;
 	}
 }
@@ -1616,7 +1622,7 @@ int __init smp_mpic_probe(void)
 
 	DBG("smp_mpic_probe()...\n");
 
-	nr_cpus = cpus_weight(cpu_possible_map);
+	nr_cpus = cpumask_weight(cpu_possible_mask);
 
 	DBG("nr_cpus: %d\n", nr_cpus);
 
Index: linux-cpumask/arch/powerpc/include/asm/mpic.h
===================================================================
--- linux-cpumask.orig/arch/powerpc/include/asm/mpic.h	2010-04-22 14:52:08.896696998 +1000
+++ linux-cpumask/arch/powerpc/include/asm/mpic.h	2010-04-22 14:52:19.915447374 +1000
@@ -463,9 +463,6 @@ extern void mpic_cpu_set_priority(int pr
 /* Request IPIs on primary mpic */
 extern void mpic_request_ipis(void);
 
-/* Send an IPI (non offseted number 0..3) */
-extern void mpic_send_ipi(unsigned int ipi_no, unsigned int cpu_mask);
-
 /* Send a message (IPI) to a given target (cpu number or MSG_*) */
 void smp_mpic_message_pass(int target, int msg);
 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [patch 15/15] powerpc: cpumask: Add DEBUG_PER_CPU_MAPS option
  2010-04-27  1:32 [patch 00/15] PowerPC cpumask patches Anton Blanchard
                   ` (13 preceding siblings ...)
  2010-04-27  1:32 ` [patch 14/15] powerpc: cpumask: Convert mpic driver to new cpumask API Anton Blanchard
@ 2010-04-27  1:32 ` Anton Blanchard
  14 siblings, 0 replies; 17+ messages in thread
From: Anton Blanchard @ 2010-04-27  1:32 UTC (permalink / raw)
  To: benh, rusty; +Cc: linuxppc-dev

Enable the DEBUG_PER_CPU_MAPS option so we can look for problems with
cpumasks .

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Index: linux-cpumask/arch/powerpc/Kconfig.debug
===================================================================
--- linux-cpumask.orig/arch/powerpc/Kconfig.debug	2010-04-22 14:51:36.359196562 +1000
+++ linux-cpumask/arch/powerpc/Kconfig.debug	2010-04-22 14:52:04.845445439 +1000
@@ -44,6 +44,18 @@ config DEBUG_STACK_USAGE
 
 	  This option will slow down process creation somewhat.
 
+config DEBUG_PER_CPU_MAPS
+	bool "Debug access to per_cpu maps"
+	depends on DEBUG_KERNEL
+	depends on SMP
+	default n
+	---help---
+	  Say Y to verify that the per_cpu map being accessed has
+	  been setup.  Adds a fair amount of code to kernel memory
+	  and decreases performance.
+
+	  Say N if unsure.
+
 config HCALL_STATS
 	bool "Hypervisor call instrumentation"
 	depends on PPC_PSERIES && DEBUG_FS && TRACEPOINTS

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch 03/15] powerpc: cpumask: Convert smp_cpus_done to new cpumask API
  2010-04-27  1:32 ` [patch 03/15] powerpc: cpumask: Convert smp_cpus_done " Anton Blanchard
@ 2010-04-28  2:09   ` Stephen Rothwell
  0 siblings, 0 replies; 17+ messages in thread
From: Stephen Rothwell @ 2010-04-28  2:09 UTC (permalink / raw)
  To: Anton Blanchard; +Cc: rusty, linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 501 bytes --]

Hi Anton,

On Tue, 27 Apr 2010 11:32:34 +1000 Anton Blanchard <anton@samba.org> wrote:
>
> -	old_mask = current->cpus_allowed;
> -	set_cpus_allowed(current, cpumask_of_cpu(boot_cpuid));
> -	
> +	alloc_cpumask_var(&old_mask, GFP_NOWAIT);

You should probably put an explicit include of linux/gfp.h in this file
for this.  (Maybe linux/cpumask.h should include it - but it doesn't.)

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2010-04-28  2:09 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [patch 12/15] powerpc: cpumask: Convert NUMA " Anton Blanchard
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

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).