cvs commit: src/sys/kern sched_ule.c

Peter Grehan grehan at freebsd.org
Tue Oct 2 13:33:52 PDT 2007


Hi Jeff,

> If you can test ULE on UP arm/powerpc I'd appreciate it.

  Works fine on ppc after some minor tweaks. I've attached the diff for 
those interested. A couple of questions:

  - Can ULE work without preemption ? When it wasn't enabled, the system 
wouldn't switch out of the idle loop. There's a comment in sched_idletd():

           /* ULE relies on preemption for idle interruption. */

    I'm asking because PREEMPTION has never been switched on in PPC, and 
it might be nice to enable ULE without having to determine if bugs are 
in PREEMPTION or ULE.

  - ppc's cpu_throw() was implemented in C. I modified it to pass the 
thread-lock mutex from the old thread, so the context switch routine 
would simply write it back. Is that an OK thing to do ?

later,

Peter.
-------------- next part --------------
Index: kern/sched_ule.c
===================================================================
RCS file: /usr/home/ncvs/src/sys/kern/sched_ule.c,v
retrieving revision 1.210
diff -d -u -r1.210 sched_ule.c
--- kern/sched_ule.c	27 Sep 2007 16:39:27 -0000	1.210
+++ kern/sched_ule.c	1 Oct 2007 00:27:37 -0000
@@ -71,7 +71,7 @@
 #include <machine/cpu.h>
 #include <machine/smp.h>
 
-#if !defined(__i386__) && !defined(__amd64__)
+#if !defined(__i386__) && !defined(__amd64__) && !defined(__powerpc__)
 #error "This architecture is not currently compatible with ULE"
 #endif
 
Index: powerpc/conf/GENERIC
===================================================================
RCS file: /usr/home/ncvs/src/sys/powerpc/conf/GENERIC,v
retrieving revision 1.71
diff -d -u -r1.71 GENERIC
--- powerpc/conf/GENERIC	26 Sep 2007 20:05:07 -0000	1.71
+++ powerpc/conf/GENERIC	2 Oct 2007 02:00:27 -0000
@@ -30,7 +30,9 @@
 options 	POWERMAC		#NewWorld Apple PowerMacs
 options 	PSIM			#GDB PSIM ppc simulator
 
-options 	SCHED_4BSD		#4BSD scheduler
+options		SCHED_ULE
+#options 	SCHED_4BSD		#4BSD scheduler
+options		PREEMPTION		#Enable kernel thread preemption
 options 	INET			#InterNETworking
 options 	INET6			#IPv6 communications protocols
 options 	SCTP			#Stream Control Transmission Protocol
Index: powerpc/powerpc/genassym.c
===================================================================
RCS file: /usr/home/ncvs/src/sys/powerpc/powerpc/genassym.c,v
retrieving revision 1.58
diff -d -u -r1.58 genassym.c
--- powerpc/powerpc/genassym.c	30 Nov 2006 04:17:05 -0000	1.58
+++ powerpc/powerpc/genassym.c	1 Oct 2007 00:08:13 -0000
@@ -137,6 +137,7 @@
 ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags));
 ASSYM(PCB_FPU, PCB_FPU);
 
+ASSYM(TD_LOCK, offsetof(struct thread, td_lock));
 ASSYM(TD_PROC, offsetof(struct thread, td_proc));
 ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
 
Index: powerpc/powerpc/swtch.S
===================================================================
RCS file: /usr/home/ncvs/src/sys/powerpc/powerpc/swtch.S,v
retrieving revision 1.21
diff -d -u -r1.21 swtch.S
--- powerpc/powerpc/swtch.S	7 Jan 2005 02:29:20 -0000	1.21
+++ powerpc/powerpc/swtch.S	1 Oct 2007 00:19:53 -0000
@@ -67,13 +67,17 @@
 #include <machine/asm.h>
 
 /*
- * void cpu_switch(struct thread *old, struct thread *new)
+ * void cpu_switch(struct thread *old,
+ *		   struct thread *new,
+ *		   struct mutex *mtx); 
  *
  * Switch to a new thread saving the current state in the old thread.
  */
 ENTRY(cpu_switch)
-	lwz	%r5,TD_PCB(%r3)		/* Get the old thread's PCB ptr */
+	stw	%r5,TD_LOCK(%r3)	/* ULE:	update old thread's lock */
+					/* XXX needs to change for MP */
 
+	lwz	%r5,TD_PCB(%r3)		/* Get the old thread's PCB ptr */
 	mr	%r12,%r2	
 	stmw	%r12,PCB_CONTEXT(%r5)	/* Save the non-volatile GP regs.
 					   These can now be used for scratch */
Index: powerpc/powerpc/vm_machdep.c
===================================================================
RCS file: /usr/home/ncvs/src/sys/powerpc/powerpc/vm_machdep.c,v
retrieving revision 1.115
diff -d -u -r1.115 vm_machdep.c
--- powerpc/powerpc/vm_machdep.c	6 Jun 2007 06:01:56 -0000	1.115
+++ powerpc/powerpc/vm_machdep.c	1 Oct 2007 01:13:50 -0000
@@ -197,7 +197,7 @@
 cpu_throw(struct thread *old, struct thread *new)
 {
 
-	cpu_switch(old, new, NULL);
+	cpu_switch(old, new, old->td_lock);
 	panic("cpu_throw() didn't");
 }
 


More information about the freebsd-ppc mailing list