From owner-freebsd-threads@FreeBSD.ORG Fri Apr 11 01:53:20 2003 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4DDF637B401 for ; Fri, 11 Apr 2003 01:53:20 -0700 (PDT) Received: from exchhz01.viatech.com.cn (ip-167-164-97-218.anlai.com [218.97.164.167]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5B7D543F3F for ; Fri, 11 Apr 2003 01:53:17 -0700 (PDT) (envelope-from davidxu@freebsd.org) Received: from davidw2k (ip-240-1-168-192.rev.dyxnet.com [192.168.1.240]) by exchhz01.viatech.com.cn with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id HLDQP5A0; Fri, 11 Apr 2003 16:39:40 +0800 Message-ID: <040c01c30008$03590590$f001a8c0@davidw2k> From: "David Xu" To: "Julian Elischer" , "Daniel Eischen" References: Date: Fri, 11 Apr 2003 16:54:51 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 cc: freebsd-threads@freebsd.org Subject: Re: patch for %gs saving X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Apr 2003 08:53:20 -0000 ----- Original Message -----=20 From: "Julian Elischer" To: "Daniel Eischen" Cc: "Peter Wemm" ; "David Xu" ; = Sent: Friday, April 11, 2003 2:54 PM Subject: Re: patch for %gs saving=20 >=20 >=20 > On Fri, 11 Apr 2003, Daniel Eischen wrote: >=20 > > On Thu, 10 Apr 2003, Peter Wemm wrote: > >=20 > > > "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 ? > > >=20 > > > 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. > > >=20 > > > 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. > > >=20 > > > Bruce Evans understands this better than I do, I would suggest not = making > > > this change without talking about it with him first. > >=20 > > 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. >=20 > 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. >=20 > %gs should never change for a single KSE as it goes in and out of the > kernel, it must always have the same mailbox. >=20 >=20 Yes, I saw some code in libpthread patch changes %gs, for example thr_switch(), thr_enter_uts(), I think such code=20 needn't change %gs, and I think even %fs, %ds, %es is needn't to be changed, this would speedup context switch. >=20 > >=20 > > --=20 > > Dan Eischen > >=20 > > _______________________________________________ > > 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" > >