From owner-freebsd-arch Wed Nov 22 11:17:33 2000 Delivered-To: freebsd-arch@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id 1895837B479 for ; Wed, 22 Nov 2000 11:17:31 -0800 (PST) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.9.3/8.9.3) id OAA47152; Wed, 22 Nov 2000 14:17:21 -0500 (EST) (envelope-from wollman) Date: Wed, 22 Nov 2000 14:17:21 -0500 (EST) From: Garrett Wollman Message-Id: <200011221917.OAA47152@khavrinen.lcs.mit.edu> To: bright@wintelcom.net Subject: Re: Thread-specific data and KSEs X-Newsgroups: mit.lcs.mail.freebsd-arch In-Reply-To: References: Organization: MIT Laboratory for Computer Science Cc: arch@freebsd.org Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG [Sorry I'm coming into this late -- I only read this list rarely, and through news at that.] In article you write: >No extra TLB faults/invalidations? Aren't segment registers >somewhat expensive to load? Segment register loads are the most expensive thing you can do, in a single instruction, on an Intel-architecture processor, that doesn't result in taking a trap.[1] Having said that, we already have some of the overhead: FS and GS are used in the kernel to limit the kernel's access when following user pointers. See the internals of copyin(), copyout(), [fs]uword(), etc. Upon entry to the kernel, we load appropriate selectors for this purpose, and restore the user's selectors on exit. However, some of the overhead is avoided for normal FreeBSD ABI applications, since we end up ``saving'' and ``restoring'' the same value all the time. (User programs don't muck with the segment registers.) If you can somehow arrange to put your pointer on the stack -- or practically anywhere else -- it would probably be preferable to using a segment register, as it would avoid the overhead of both segment register loads and LDTR loads. (IIRC, when you load the LDTR it automatically flushes the segment attribute cache, which ensures that future segment register loads are as expensive as possible.) -GAWollman [1] Well, perhaps this is no longer true. It was true at least up to the first-generation Pentium. WinNT 3.51 spent something like a third of its context-switch time on seg-reg loads. -- Garrett A. Wollman | O Siem / We are all family / O Siem / We're all the same wollman@lcs.mit.edu | O Siem / The fires of freedom Opinions not those of| Dance in the burning flame MIT, LCS, CRS, or NSA| - Susan Aglukark and Chad Irschick To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message