Re: 4k stacks in 2.6

From: Brian Gerst
Date: Thu May 27 2004 - 14:29:39 EST


Guy Sotomayor wrote:

On Thu, 2004-05-27 at 07:55, Linus Torvalds wrote:


"minor implementation detail"?

You need to get to the thread info _some_ way, and you need to get to it
_fast_. There are really no sane alternatives. I certainly do not want to
play games with segments.


While segments on x86 are in general to be avoided (aka the 286
segmented memory models) they can be useful for some things in the
kernel.

Here's a couple of examples:
* dereference gs:0 to get the thread info. The first element in
the structure is its linear address (ie usable for being deref'd
off of DS).

The only problem with using %gs as a base register is that reloading it on every entry and exit is rather expensive (GDT access and priviledge checks) compared to masking bits off %esp. x86-64 can get away with it because it has the swapgs instruction which makes it efficient to use.

* use SS to enforce the stack limit. This way you'd absolutely
get an exception when there was a stack overflow (underflow). SS gets reloaded on entry into the kernel and on interrupts
anyway so there really shouldn't be a performance impact. I
haven't looked at all the (potential) gcc implications here so
this one may not be completely doable.

Not possible. GCC completely assumes that we are working with a single flat address space. It has no concept of segmentation at all.

--
Brian Gerst
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/