patch for %gs saving

Peter Wemm peter at wemm.org
Thu Apr 10 22:37:23 PDT 2003


"David Xu" wrote:
> Here is the patch for kernel to save %gs,
> it works well on my machine.
> http://people.freebsd.org/~davidxu/i386_gs.diff
> Daniel, is this the reason in your libpthread
> patch that doesn't use getcontext syscall ?

To put some background on the issue, there is a reason why we did not
do this.  %gs is not used by the kernel, so it does not normally need to
be saved and restored on every trap into the kernel.  Setting a segment
register is Really Slow - measured in hundreds of clock cycles.

So, we normally only touch %gs when we context switch to a different process
that may have a different %gs.  Or when one of the context syscalls wants
it changed.  We cannot avoid touching %fs because we use it for kernel
private data.  But if it wasn't for that, we wouldn't be touching
%fs for regular traps/syscalls/etc either.

Bruce Evans understands this better than I do, I would suggest not making
this change without talking about it with him first.

Cheers,
-Peter
--
Peter Wemm - peter at wemm.org; peter at FreeBSD.org; peter at yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5



More information about the freebsd-threads mailing list