From owner-p4-projects@FreeBSD.ORG Tue Apr 26 18:30:05 2005 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B620616A550; Tue, 26 Apr 2005 18:30:04 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 83C1816A640 for ; Tue, 26 Apr 2005 18:30:04 +0000 (GMT) Received: from mail24.sea5.speakeasy.net (mail24.sea5.speakeasy.net [69.17.117.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 159D343D2F for ; Tue, 26 Apr 2005 18:30:04 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: (qmail 6725 invoked from network); 26 Apr 2005 18:30:03 -0000 Received: from server.baldwin.cx ([216.27.160.63]) (envelope-sender )AES256-SHA encrypted SMTP for ; 26 Apr 2005 18:30:03 -0000 Received: from roboboy.corp.weather.com (gw1.twc.weather.com [216.133.140.1]) (authenticated bits=0) by server.baldwin.cx (8.13.1/8.13.1) with ESMTP id j3QITfvT034307; Tue, 26 Apr 2005 14:29:57 -0400 (EDT) (envelope-from jhb@FreeBSD.org) From: John Baldwin To: David Xu Date: Tue, 26 Apr 2005 13:20:30 -0400 User-Agent: KMail/1.8 References: <200504171042.j3HAgeTQ054345@repoman.freebsd.org> <87f1dd37c46f5e61c68035b9989ae5b7@FreeBSD.org> <426E43C5.20401@freebsd.org> In-Reply-To: <426E43C5.20401@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200504261320.31661.jhb@FreeBSD.org> X-Spam-Status: No, score=-102.8 required=4.2 tests=ALL_TRUSTED, USER_IN_WHITELIST autolearn=failed version=3.0.2 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on server.baldwin.cx cc: Perforce Change Reviews Subject: Re: PERFORCE change 75366 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Apr 2005 18:30:05 -0000 On Tuesday 26 April 2005 09:36 am, David Xu wrote: > John Baldwin wrote: > > On Apr 17, 2005, at 6:42 AM, David Xu wrote: > >> http://perforce.freebsd.org/chv.cgi?CH=75366 > >> > >> Change 75366 by davidxu@davidxu_alona on 2005/04/17 10:42:05 > >> > >> Implement cpu_set_user_tls for sparc64. > >> > >> Affected files ... > >> > >> .. > >> //depot/projects/davidxu_thread/src/sys/sparc64/sparc64/vm_machdep.c#6 > >> edit > >> > >> Differences ... > >> > >> ==== > >> //depot/projects/davidxu_thread/src/sys/sparc64/sparc64/vm_machdep.c#6 > >> (text+ko) ==== > >> > >> @@ -194,6 +194,15 @@ > >> td->td_retval[1] = tf->tf_out[1]; > >> } > >> > >> +void > >> +cpu_set_user_tls(struct thread *td, void *tls_base, size_t tls_size, > >> + int tls_seg __unused) > >> +{ > >> + if (td == curthread) > >> + flushw(); > >> + td->td_frame->tf_global[7] = tls_base; > >> +} > >> + > > > > I think for at least this one and Alpha you might want a critical > > section in the curthread case like you do on i386 and amd64 since > > calling the Alpha PAL and setting tls_base + flushw() are more than > > one instruction long. > > If this is true, why don't set_mcontext on sparc64 and alpha enter > critical region ? Bugs. :) Actually, sparc64 is probably ok, but alpha_pal_wrunique() on Alpha is basically the same as wrmsr() on x86. You might be ok without a critical section on Alpha but I'm not sure. Actually, I think you are fine. The thread can't get out into userland without resuming and finishing this function first. > I enter critical region on i386 and amd64, because I have to write > global register (amd64 MSR) or gdt on i386, if thread is preempted, > then it may be in intermediate state, for example on amd64: > td->td_pcb->pcb_fsbase = (register_t)tls_base; > ---> > wrmsr(MSR_FSBASE, td->td_pcb->pcb_fsbase); > > if thread is preempted at ---->, a rdmsr in cpu_switch() will overwrite > the value I set before I can write it into MSR_FSBASE register. > > David Xu -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org