From owner-cvs-all@FreeBSD.ORG Thu Jul 24 14:00:01 2003 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AF2FD37B407 for ; Thu, 24 Jul 2003 14:00:01 -0700 (PDT) Received: from mail.speakeasy.net (mail15.speakeasy.net [216.254.0.215]) by mx1.FreeBSD.org (Postfix) with ESMTP id EDEA543F93 for ; Thu, 24 Jul 2003 13:59:59 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: (qmail 3607 invoked from network); 24 Jul 2003 20:59:59 -0000 Received: from unknown (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender )encrypted SMTP for ; 24 Jul 2003 20:59:59 -0000 Received: from laptop.baldwin.cx (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.12.9/8.12.9) with ESMTP id h6OKxvGI049707; Thu, 24 Jul 2003 16:59:57 -0400 (EDT) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.5.4 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20030724191943.GA1028@dhcp01.pn.xcllnt.net> Date: Thu, 24 Jul 2003 17:00:13 -0400 (EDT) From: John Baldwin To: Marcel Moolenaar cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/lib/libthr/arch/alpha/alpha _curthread.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jul 2003 21:00:02 -0000 On 24-Jul-2003 Marcel Moolenaar wrote: > On Thu, Jul 24, 2003 at 03:08:32PM -0400, John Baldwin wrote: >> >> On 24-Jul-2003 Marcel Moolenaar wrote: >> > marcel 2003/07/24 00:51:49 PDT >> > >> > FreeBSD src repository >> > >> > Modified files: >> > lib/libthr/arch/alpha/alpha _curthread.c >> > Log: >> > Implement _get_curthread and _set_curthread. We use GCCs builtin >> > function this, which expands to PAL calls (rduniq and wruniq). >> > This needs adjustment when TLS is implemented. >> >> This trashes SMP since we use the per-CPU unique value already >> to maintain the per-cpu data pointer. > > Writing to the per-CPU unique value is an unprivileged operation. > You cannot possibly use that for in-kernel use without saving and > restoring it on kernel exit/entry. Which is what needs to be done. There is a chicken and egg problem. We use the unique value to initialize the per-cpu pointer on kernel entry. We only have one such beast, and in the kernel we cache it in a register that userland gets to clobber (and frequently does). If you can think of a better way to store the per-cpu pointer such that kernel entry can load it into the register go for it. Read some code: syscall(...) { ... /* * Find our per-cpu globals. */ #ifdef SMP s = intr_disable(); #endif pcpup = (struct pcpu *) alpha_pal_rdval(); td = curthread; #ifdef SMP td->td_md.md_kernnest++; intr_restore(s); #endif ... } -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/