cpumask move patch revised - RFC

R Sharada sharada at in.ibm.com
Fri Aug 20 18:52:01 EST 2004


Hello,
	I have made a new patch for the cpumask move, against linus 2.6.8.1
tree. I don't see Nathan's changes in there yet, so this patch still works
with the old cpumasks, and not with Nathan's cleaned up ones.

The patch includes:
- move the cpumask_setup function from chrp_setup.c to setup.c
- remove extern function declarations in setup.c
- remove the of_node_put() call outside the while loop

Please review, test and provide comments.

Thanks and Regards,
Sharada

On Fri, Aug 13, 2004 at 04:20:22PM +1000, Paul Mackerras wrote:
>
> R Sharada writes:
>
> > Yes, you are correct. I did see Nathan's patch on the removal of the
> > unnecessary cpu maps. And yes, I am waiting for his patch to go first
> > and then have this reworked to match that change.
>
> I have just sent Nathan's patches on to Andrew Morton.
>
> > > Is this really necessary?  Might it go better in a .h file somewhere?
> >
> > Well, yes, perhaps it could be put in some .h file. However, the idea here
> > was that, I just followed the conventions for other functions in chrp_setup.c
> > file
>
> Hmmm.  Anything that is defined in one file and referenced in another
> should be declared in a header, not in the individual C files.  Put it
> in asm-ppc64/smp.h (unless you can think of a better place).  Either
> that or move cpumask_setup() into setup.c.
>
> > As regards the of_node_put, discussing with Nathan, I realized that it isn't
> > really necessary, even for the last cpu node data structure in the while
> > loop. So, this of_node_put will be gone soon, in the next patch.
>
> Note that it is not necessary because np is NULL by the time you exit
> the loop.
>
> > > I think it is about time we start making code that will deal with more
> > > than 2 cpu_threads, as the processors seem inevitable and not too far off.
> > >
> > So, can SMT/HMT have more than 2 threads now? or planned in the near future?
>
> Not that I know of. :)  There are diminishing returns from having more
> than 2 threads.  If we ever get more than 2 threads we can change the
> code then, but that won't be in the next few years at least.
>
> > > Again I'd have the CONFIG_SMP cover more.  The whole while loop and the
> > > of_node_put.
> > >
> > However, here we still need to be able to check cpu node status and
> > interrupt-server#s property, etc. for non-SMP (UP) systems as well,
> > is it not? In that case, we can't really move the while loop inside the
> > #ifdef SMP, can we?
> > The case that you are talking about ( iterating  over the cpus and not doing
> > anything ) would occur only in the case of a SMP machine running a UP
> > kernel, is it not? That seems unlikely? Or are there other scenarios?
>
> That would be an uncommon case, and performance is not critical.  I
> would like to see such optimizations as a second patch after we have
> moved the code and tested it.
>
> Regards,
> Paul.
>
>
-------------- next part --------------
diff -Naur linux-2.5-org/arch/ppc64/kernel/chrp_setup.c linux-2.5-chg/arch/ppc64/kernel/chrp_setup.c
--- linux-2.5-org/arch/ppc64/kernel/chrp_setup.c	2004-08-19 01:15:24.000000000 -0700
+++ linux-2.5-chg/arch/ppc64/kernel/chrp_setup.c	2004-08-19 23:59:12.000000000 -0700
@@ -77,6 +77,7 @@
 void pSeries_calibrate_decr(void);
 void fwnmi_init(void);
 extern void SystemReset_FWNMI(void), MachineCheck_FWNMI(void);	/* from head.S */
+
 int fwnmi_active;  /* TRUE if an FWNMI handler is present */

 dev_t boot_dev;
@@ -462,3 +463,4 @@

 	setup_default_decr();
 }
+
diff -Naur linux-2.5-org/arch/ppc64/kernel/prom.c linux-2.5-chg/arch/ppc64/kernel/prom.c
--- linux-2.5-org/arch/ppc64/kernel/prom.c	2004-08-19 01:15:25.000000000 -0700
+++ linux-2.5-chg/arch/ppc64/kernel/prom.c	2004-08-19 23:49:58.000000000 -0700
@@ -939,13 +939,6 @@
 			prom_getprop(node, "reg", &reg, sizeof(reg));
 			lpaca[cpuid].hw_cpu_id = reg;

-#ifdef CONFIG_SMP
-			cpu_set(cpuid, RELOC(cpu_available_map));
-			cpu_set(cpuid, RELOC(cpu_possible_map));
-			cpu_set(cpuid, RELOC(cpu_present_at_boot));
-			if (reg == 0)
-				cpu_set(cpuid, RELOC(cpu_online_map));
-#endif /* CONFIG_SMP */
 			cpuid++;
 		}
 		return;
@@ -1042,9 +1035,6 @@
 #ifdef CONFIG_SMP
 				/* Set the number of active processors. */
 				_systemcfg->processorCount++;
-				cpu_set(cpuid, RELOC(cpu_available_map));
-				cpu_set(cpuid, RELOC(cpu_possible_map));
-				cpu_set(cpuid, RELOC(cpu_present_at_boot));
 #endif
 			} else {
 				prom_printf("... failed: %x\n", *acknowledge);
@@ -1053,10 +1043,6 @@
 #ifdef CONFIG_SMP
 		else {
 			prom_printf("%x : booting  cpu %s\n", cpuid, path);
-			cpu_set(cpuid, RELOC(cpu_available_map));
-			cpu_set(cpuid, RELOC(cpu_possible_map));
-			cpu_set(cpuid, RELOC(cpu_online_map));
-			cpu_set(cpuid, RELOC(cpu_present_at_boot));
 		}
 #endif
 next:
@@ -1069,13 +1055,6 @@
 			lpaca[cpuid].hw_cpu_id = interrupt_server[i];
 			prom_printf("%x : preparing thread ... ",
 				    interrupt_server[i]);
-			if (_naca->smt_state) {
-				cpu_set(cpuid, RELOC(cpu_available_map));
-				cpu_set(cpuid, RELOC(cpu_present_at_boot));
-				prom_printf("available\n");
-			} else {
-				prom_printf("not available\n");
-			}
 		}
 #endif
 		cpuid++;
@@ -1101,8 +1080,6 @@
 						pir & 0x3ff;
 				}
 			}
-/* 			cpu_set(i+1, cpu_online_map); */
-			cpu_set(i+1, RELOC(cpu_possible_map));
 		}
 		_systemcfg->processorCount *= 2;
 	} else {
diff -Naur linux-2.5-org/arch/ppc64/kernel/setup.c linux-2.5-chg/arch/ppc64/kernel/setup.c
--- linux-2.5-org/arch/ppc64/kernel/setup.c	2004-08-19 01:15:25.000000000 -0700
+++ linux-2.5-chg/arch/ppc64/kernel/setup.c	2004-08-20 01:34:24.037909496 -0700
@@ -89,6 +89,7 @@
 void parse_cmd_line(unsigned long r3, unsigned long r4, unsigned long r5,
 		    unsigned long r6, unsigned long r7);
 int parse_bootinfo(void);
+void cpumask_setup(void);

 #ifdef CONFIG_MAGIC_SYSRQ
 unsigned long SYSRQ_KEY;
@@ -229,6 +230,7 @@
 		register_console(&udbg_console);
 		__irq_offset_value = NUM_ISA_INTERRUPTS;
 		finish_device_tree();
+		cpumask_setup();
 		chrp_init(r3, r4, r5, r6, r7);

 #ifdef CONFIG_SMP
@@ -251,6 +253,7 @@
 #ifdef CONFIG_PPC_PMAC
 	if (systemcfg->platform == PLATFORM_POWERMAC) {
 		finish_device_tree();
+		cpumask_setup();
 		pmac_init(r3, r4, r5, r6, r7);
 	}
 #endif /* CONFIG_PPC_PMAC */
@@ -750,6 +753,91 @@

 }

+void cpumask_setup()
+{
+        unsigned long ind;
+        struct device_node *np = NULL;
+        int cpuid = 0;
+        unsigned int *reg;
+        char *statusp;
+        int prop;
+        int *propsize = ∝
+        unsigned int cpu_threads;
+
+        printk(KERN_INFO "cpumask_setup\n");
+        /* On pmac, we just fill out the various global bitmasks and
+        * arrays indicating our CPUs are here, they are actually started
+        * later on from pmac_smp
+        */
+        if (systemcfg->platform == PLATFORM_POWERMAC) {
+                while ((np = of_find_node_by_type(np, "cpu"))) {
+                        reg = (unsigned int *)get_property(np, "reg", NULL);
+#ifdef CONFIG_SMP
+                        cpu_set(cpuid, cpu_available_map);
+                        cpu_set(cpuid, cpu_possible_map);
+                        cpu_set(cpuid, cpu_present_at_boot);
+                        if (*reg == 0)
+                                cpu_set(cpuid, cpu_online_map);
+#endif /* CONFIG_SMP */
+                        cpuid++;
+                }
+                return;
+        }
+
+        while ((np = of_find_node_by_type(np, "cpu"))) {
+
+                statusp = (char *)get_property(np, "status", NULL);
+                if ((statusp == NULL) || (statusp && strcmp(statusp, "okay") !=
+0))
+                        continue;
+
+                reg = (unsigned int *)get_property(np, "reg", NULL);
+                get_property(np, "ibm,ppc-interrupt-server#s", propsize);
+                if (*propsize < 0) {
+                        /* no property.  old hardware has no SMT */
+                        cpu_threads = 1;
+                } else {
+                        /* We have a threaded processor */
+                        cpu_threads = *propsize / sizeof(u32);
+                        if (cpu_threads > 2)
+                        cpu_threads = 1; /* ToDo: panic? */
+                }
+
+#ifdef CONFIG_SMP
+                cpu_set(cpuid, cpu_available_map);
+                cpu_set(cpuid, cpu_possible_map);
+                cpu_set(cpuid, cpu_present_at_boot);
+                if (cpuid == boot_cpuid)
+                cpu_set(cpuid, cpu_online_map);
+                /* set the secondary threads into the cpuid mask */
+                for (ind=1; ind < cpu_threads; ind++) {
+                        cpuid++;
+                        if (cpuid >= NR_CPUS)
+                                continue;
+                        if (naca->smt_state) {
+                                cpu_set(cpuid, cpu_available_map);
+                                cpu_set(cpuid, cpu_present_at_boot);
+                        }
+                }
+#endif /* CONFIG_SMP */
+                cpuid++;
+        }
+
+#ifdef CONFIG_HMT
+        /* Only enable HMT on processors that provide support. */
+        if (__is_processor(PV_PULSAR) ||
+         __is_processor(PV_ICESTAR) ||
+         __is_processor(PV_SSTAR)) {
+                for (ind = 0; ind < NR_CPUS; ind += 2) {
+                        if (!cpu_online(ind))
+                                continue;
+                        cpu_set(ind+1, cpu_possible_map);
+                }
+        }
+#endif
+        return;
+}
+
 __setup("spread_lpevents=", set_spread_lpevents );
 __setup("decr_overclock_proc0=", set_decr_overclock_proc0 );
 __setup("decr_overclock=", set_decr_overclock );


More information about the Linuxppc64-dev mailing list