From owner-freebsd-current Thu Jul 11 19:16:43 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3BC3937B400; Thu, 11 Jul 2002 19:16:40 -0700 (PDT) Received: from canning.wemm.org (canning.wemm.org [192.203.228.65]) by mx1.FreeBSD.org (Postfix) with ESMTP id A156B43E64; Thu, 11 Jul 2002 19:16:39 -0700 (PDT) (envelope-from peter@wemm.org) Received: from fw.wemm.org (canning.wemm.org [192.203.228.65]) by canning.wemm.org (Postfix) with ESMTP id 888282A7F2; Thu, 11 Jul 2002 19:16:39 -0700 (PDT) (envelope-from peter@wemm.org) Received: from overcee.wemm.org (overcee.wemm.org [10.0.0.3]) by fw.wemm.org (Postfix) with ESMTP id 489944C2B9; Thu, 11 Jul 2002 19:16:39 -0700 (PDT) (envelope-from peter@wemm.org) Received: from wemm.org (localhost [127.0.0.1]) by overcee.wemm.org (Postfix) with ESMTP id ECDE8380A; Thu, 11 Jul 2002 19:16:39 -0700 (PDT) (envelope-from peter@wemm.org) X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: John Baldwin Cc: julian@FreeBSD.org, current@FreeBSD.org Subject: Re: Thread state In-Reply-To: Date: Thu, 11 Jul 2002 19:16:39 -0700 From: Peter Wemm Message-Id: <20020712021639.ECDE8380A@overcee.wemm.org> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG John Baldwin wrote: > Currently, sparc64 SMP panics before getting out of single user mode > because there is an optimization case in cpu_switch() (if we are > switching back to the same thread, we just return right away) that > doesn't set td_state to TDS_RUNNING. Also, according to Peter, the > code in ia64's cpu_switch() doesn't work either. Rather than try to > fix this in the assembler though, I think it is easier to just set > the thread state once in C at the end of choosethread(). It is a > lot easier to maintain down the road. The patch to do this is at > http://www.freebsd.org/~jhb/patches/kse_switch.patch > > It has been tested on sparc64, alpha, and i386 all with SMP. I > would like to commit it soonish. Comments? I like your patch much better. I had to use this alternative change to the ia64 source - the cvs version doesn't compile. ie: Change this: @@ -283,6 +283,12 @@ st8 [r14]=r4 // set r13->pc_curthread mov ar.k7=r4 ;; +// Julian's guess at settinghte thread state + add r15=TD_STATE,r4 + ;; + mov [r15]=TDS_RUNNING + ;; +// end of julian's guess add r15=TD_PCB,r4 ;; ld8 r15=[r15] to something more like this: @@ -284,8 +284,11 @@ mov ar.k7=r4 ;; add r15=TD_PCB,r4 + add r16=TD_STATE,r4 + mov r17=TDS_RUNNING ;; ld8 r15=[r15] + st8 [r16]=r17 ;; add r15=PCB_PMAP,r15 // &pcb_pmap ;; I think I'd rather that we did it in C, since we have a convenient spot to do it. My feeble attempt isn't exactly optimal either. I'd expect the compiler to do an increasingly [over time] better job. Cheers, -Peter -- Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com "All of this is for nothing if we don't go to the stars" - JMS/B5 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message