Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Nov 2000 14:17:21 -0500 (EST)
From:      Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
To:        bright@wintelcom.net
Cc:        arch@freebsd.org
Subject:   Re: Thread-specific data and KSEs
Message-ID:  <200011221917.OAA47152@khavrinen.lcs.mit.edu>
In-Reply-To: <mit.lcs.mail.freebsd-arch/20001121192331.E18037@fw.wintelcom.net>
References:  <mit.lcs.mail.freebsd-arch/20001121175100.B18037@fw.wintelcom.net> <mit.lcs.mail.freebsd-arch/Pine.SUN.3.91.1001121221431.26351B-100000@pcnet1.pcnet.com>

next in thread | previous in thread | raw e-mail | index | archive | help
[Sorry I'm coming into this late -- I only read this list rarely, and
through news at that.]

In article <mit.lcs.mail.freebsd-arch/20001121192331.E18037@fw.wintelcom.net> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200011221917.OAA47152>