From owner-freebsd-ppc@FreeBSD.ORG Tue Oct 2 20:33:52 2007 Return-Path: Delivered-To: freebsd-ppc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EB16C16A419 for ; Tue, 2 Oct 2007 20:33:51 +0000 (UTC) (envelope-from grehan@freebsd.org) Received: from dommail.onthenet.com.au (dommail.OntheNet.com.au [203.13.70.57]) by mx1.freebsd.org (Postfix) with ESMTP id 7395413C4BD for ; Tue, 2 Oct 2007 20:33:51 +0000 (UTC) (envelope-from grehan@freebsd.org) Received: from excfreebsd.hq.netapp.com (nat-198-95-226-228.netapp.com [198.95.226.228]) by dommail.onthenet.com.au (MOS 3.7.5a-GA) with ESMTP id DED69532 (AUTH peterg@ptree32.com.au); Wed, 3 Oct 2007 06:33:36 +1000 (EST) Message-ID: <4702AB13.3060003@freebsd.org> Date: Tue, 02 Oct 2007 13:33:23 -0700 From: Peter Grehan User-Agent: Thunderbird 2.0.0.0 (X11/20070525) MIME-Version: 1.0 To: Jeff Roberson References: <200709271639.l8RGdREd032105@repoman.freebsd.org> <46FBDFE8.9050909@freebsd.org> <20070930153101.T583@10.0.0.1> <47004ACF.5020901@freebsd.org> <20070930184601.R583@10.0.0.1> In-Reply-To: <20070930184601.R583@10.0.0.1> Content-Type: multipart/mixed; boundary="------------090209030005060901090007" Cc: freebsd-ppc@freebsd.org Subject: Re: cvs commit: src/sys/kern sched_ule.c X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: grehan@freebsd.org List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Oct 2007 20:33:52 -0000 This is a multi-part message in MIME format. --------------090209030005060901090007 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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. --------------090209030005060901090007 Content-Type: text/plain; name="ule.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ule.diff" 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 #include -#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 /* - * 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"); } --------------090209030005060901090007--