From owner-freebsd-threads@FreeBSD.ORG Thu Apr 10 22:37:22 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 E5FDD37B401; Thu, 10 Apr 2003 22:37:22 -0700 (PDT) Received: from canning.wemm.org (canning.wemm.org [192.203.228.65]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8EF5F43F85; Thu, 10 Apr 2003 22:37:22 -0700 (PDT) (envelope-from peter@wemm.org) Received: from wemm.org (localhost [127.0.0.1]) by canning.wemm.org (Postfix) with ESMTP id 782152A7EA; Thu, 10 Apr 2003 22:37:22 -0700 (PDT) (envelope-from peter@wemm.org) X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: "David Xu" In-Reply-To: <008001c2ffe8$056584f0$f001a8c0@davidw2k> Date: Thu, 10 Apr 2003 22:37:22 -0700 From: Peter Wemm Message-Id: <20030411053722.782152A7EA@canning.wemm.org> 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 05:37:23 -0000 "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@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com "All of this is for nothing if we don't go to the stars" - JMS/B5