Date: Thu, 24 Jul 2003 17:00:13 -0400 (EDT) From: John Baldwin <jhb@FreeBSD.org> To: Marcel Moolenaar <marcel@xcllnt.net> Cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/lib/libthr/arch/alpha/alpha _curthread.c Message-ID: <XFMail.20030724170013.jhb@FreeBSD.org> In-Reply-To: <20030724191943.GA1028@dhcp01.pn.xcllnt.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <jhb@FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.20030724170013.jhb>