Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Apr 2003 23:54:04 -0700 (PDT)
From:      Julian Elischer <julian@elischer.org>
To:        Daniel Eischen <eischen@pcnet1.pcnet.com>
Cc:        freebsd-threads@freebsd.org
Subject:   Re: patch for %gs saving 
Message-ID:  <Pine.BSF.4.21.0304102351360.94222-100000@InterJet.elischer.org>
In-Reply-To: <Pine.GSO.4.10.10304110200340.23482-100000@pcnet1.pcnet.com>

next in thread | previous in thread | raw e-mail | index | archive | help


On Fri, 11 Apr 2003, Daniel Eischen wrote:

> On Thu, 10 Apr 2003, Peter Wemm wrote:
> 
> > "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.
> 
> BTW, it's not really a big deal for the UTS to restore %gs
> (or probably whatever it ends up being on other archs) before
> continuing a thread.

I put it to you that %gs should be a way of finding the current KSE
mailbox
(upcall mailbox) which will NOT CHANGE when a thread is changed in
userland. one simply changes the curthread pointer in the KSE (upcall)
mailbox, leaving %gs the same.

%gs should never change for a single KSE as it goes in and out of the
kernel, it must always have the same mailbox.



> 
> -- 
> Dan Eischen
> 
> _______________________________________________
> freebsd-threads@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-threads
> To unsubscribe, send any mail to "freebsd-threads-unsubscribe@freebsd.org"
> 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0304102351360.94222-100000>