4k stacks in 2.6
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 3 lines · Ingo Molnar
do you realize that the 4K stacks feature also adds a separate softirq and a separate hardirq stack? So the maximum footprint is 4K+4K+4K, with
A nice combination would be 8K process stacks with separate irq stacks on i386.
Any chance the CONFIGs for those two could be split?
-Andi
Quoted 9 lines · Andi Kleen
Quoted 3 lines · Ingo Molnar
do you realize that the 4K stacks feature also adds a separate softirq and a separate hardirq stack? So the maximum footprint is 4K+4K+4K, with
A nice combination would be 8K process stacks with separate irq stacks on i386.
Any chance the CONFIGs for those two could be split?
Any reason not to enable interrupt stacks unconditionally and leave the stack size choice to the user?
Quoted 6 lines · On Wed, May 26, 2004 at 02:17:34PM -0400, [email protected] wrote:
Quoted 5 lines · Andi Kleen
Quoted 3 lines · Ingo Molnar
do you realize that the 4K stacks feature also adds a separate softirq and a separate hardirq stack? So the maximum footprint is 4K+4K+4K, with
Quoted 7 lines
Quoted 4 lines
A nice combination would be 8K process stacks with separate irq stacks on i386.
Any chance the CONFIGs for those two could be split?
Any reason not to enable interrupt stacks unconditionally and leave the stack size choice to the user?
It will probably still break some other patches, like debuggers.
Given that the kernel is supposed to be stable I would not change it unconditionally in 2.6. Maybe in 2.7.
-Andi
Quoted 9 lines · Andi Kleen
Quoted 3 lines · Ingo Molnar
do you realize that the 4K stacks feature also adds a separate softirq and a separate hardirq stack? So the maximum footprint is 4K+4K+4K, with
A nice combination would be 8K process stacks with separate irq stacks on i386.
Any chance the CONFIGs for those two could be split?
Couldn't this just be done with a THREAD_SIZE config option?
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 2 lines · David S. Miller
Quoted 2 lines
Change gcc to catch stack overflows before the fact and disallow module load unless modules have those checks as well.
It's impossible to do anything but panic, so it's not too helpful in practice. You can only do better for interrupts
(not handle an interrupt when the stack is too low).
Quoted 3 lines
That's easy, just enable profiling then implement a suitable
_mcountthat checks for stack overflow. I bet someone has done this already.
I did it for x86-64 a long time ago. Should be easy to port to i386 too.
ftp://ftp.x86-64.org/pub/linux/debug/stackcheck-1
-Andi
Quoted 7 lines · Andi Kleen
Quoted 2 lines · David S. Miller
Quoted 2 lines
Change gcc to catch stack overflows before the fact and disallow module load unless modules have those checks as well.
It's impossible to do anything but panic, so it's not too helpful in practice.
Oh, panic is *very* helpful. Panic won't do random funny things, it will just stop the machine. If we got an immediate panic on any stack overflow, I would want 4k stacks right now.
Quoted 8 lines
Quoted 3 lines
That's easy, just enable profiling then implement a suitable
_mcountthat checks for stack overflow. I bet someone has done this already.I did it for x86-64 a long time ago. Should be easy to port to i386 too.
ftp://ftp.x86-64.org/pub/linux/debug/stackcheck-1
Cool! If that is included, I don't have any objections against 4k stacks anymore.
Jörn
Signature · 3 lines
The cheapest, fastest and most reliable components of a computer system are those that aren't there. -- Gordon Bell, DEC labratories
Quoted 2 lines · Jörn Engel
Cool! If that is included, I don't have any objections against 4k stacks anymore.
note that it will introduce an huge slowdown, there's no way to enable that in production. But for testing it's fine.
Quoted 6 lines · Andrea Arcangeli
Quoted 2 lines · Jörn Engel
Cool! If that is included, I don't have any objections against 4k stacks anymore.
note that it will introduce an huge slowdown, there's no way to enable that in production. But for testing it's fine.
Would it be possible to add something short to the function preamble on x86 then? Similar to this code, maybe:
if (!(stack_pointer & 0xe00)) /* less than 512 bytes left */
*NULL = 1;
Not sure how this can be translated into short and fast x86 assembler, but if it is possible, I would really like to have it. Then all we have left to do is make sure no function ever uses more than 512 bytes. Famous last words, I know.
Jörn
Signature · 2 lines
Time? What's that? Time is only worth what you do with it. -- Theo de Raadt
Quoted 11 lines · Jörn Engel
Quoted 6 lines · Andrea Arcangeli
Quoted 2 lines · Jörn Engel
Cool! If that is included, I don't have any objections against 4k stacks anymore.
note that it will introduce an huge slowdown, there's no way to enable that in production. But for testing it's fine.
Would it be possible to add something short to the function preamble on x86 then? Similar to this code, maybe:
Quoted 7 lines
if (!(stack_pointer &
0xe00)) /* less than 512 bytes left */*NULL = 1;Not sure how this can be translated into short and fast x86 assembler, but if it is possible, I would really like to have it. Then all we have left to do is make sure no function ever uses more than 512 bytes. Famous last words, I know.
If it would be _inlined_ it would be *much* faster, but it would likely be measurable anyways. Less measurable though. There's no way with gcc to inline the above in the preamble, one could hack gcc for it though (there's exactly an asm preable thing in gcc that is the one that is currently implemented as call mcount plus the register saving, chaning it to the above may be feasible, though it would need a new option in gcc)
another nice thing to have (this one zerocost at runtime) would be a way to set a limit on the size of the local variables for each function. gcc knows that value very well, it's the sub it does on the stack pointer the first few asm instructions after the call. That would reduce the common mistakes. An equivalent script is the one from Keith Owens checking the vmlinux binary after compilation but I'm afraid people runs that one only after the fact.
Quoted 13 lines · Andrea Arcangeli
Quoted 11 lines · Jörn Engel
Would it be possible to add something short to the function preamble on x86 then? Similar to this code, maybe:
if (!(stack_pointer &
0xe00)) /* less than 512 bytes left */*NULL = 1;Not sure how this can be translated into short and fast x86 assembler, but if it is possible, I would really like to have it. Then all we have left to do is make sure no function ever uses more than 512 bytes. Famous last words, I know.
Quoted 7 lines
If it would be _inlined_ it would be *much* faster, but it would likely be measurable anyways. Less measurable though. There's no way with gcc to inline the above in the preamble, one could hack gcc for it though (there's exactly an asm preable thing in gcc that is the one that is currently implemented as call mcount plus the register saving, chaning it to the above may be feasible, though it would need a new option in gcc)
It is on my list, although I care more about ppc32. Can anyone translate the above into assembler?
Quoted 7 lines
another nice thing to have (this one zerocost at runtime) would be a way to set a limit on the size of the local variables for each function. gcc knows that value very well, it's the sub it does on the stack pointer the first few asm instructions after the call. That would reduce the common mistakes. An equivalent script is the one from Keith Owens checking the vmlinux binary after compilation but I'm afraid people runs that one only after the fact.
Plus the script is wrong sometimes. I have had trouble with sizes around 4G or 2G, and never found the time to really figure out what's going on. Might be an alloca thing that got misparsed somehow.
Having the check in gcc should cause less surprises.
Jörn
Signature · 2 lines
It's not whether you win or lose, it's how you place the blame. -- unknown
Quoted 9 lines · On Thu, 27 May 2004 16:59:35 +0200, =?iso-8859-1?Q?J=F6rn?= Engel…
Quoted 4 lines · Andrea Arcangeli
On Thu, May 27, 2004 at 04:15:47PM +0200, Jörn Engel wrote:
An equivalent script is the one from Keith
Owens checking the vmlinux binary after compilation but I'm afraid people runs that one only after the fact.Plus the script is wrong sometimes. I have had trouble with sizes around 4G or 2G, and never found the time to really figure out what's going on. Might be an alloca thing that got misparsed somehow.
Some code results in negative adjustments to the stack size on exit, which look like 4G sizes. My script checks for those and ignores them. /^[89a-f].......$/d;
Quoted 10 lines · Keith Owens
Quoted 4 lines · On Thu, 27 May 2004 16:59:35 +0200, =?iso-8859-1?Q?J=F6rn?= Engel…
Plus the script is wrong sometimes. I have had trouble with sizes around 4G or 2G, and never found the time to really figure out what's going on. Might be an alloca thing that got misparsed somehow.
Some code results in negative adjustments to the stack size on exit, which look like 4G sizes. My script checks for those and ignores them. /^[89a-f].......$/d;
Ok, looks as if only my script is wrong. Do you know what exactly causes such a negative adjustment?
Jörn
Signature · 3 lines
Optimizations always bust things, because all optimizations are, in the long haul, a form of cheating, and cheaters eventually get caught. -- Larry Wall
Quoted 8 lines · Jörn Engel
Quoted 7 lines · Keith Owens
Quoted 4 lines · On Thu, 27 May 2004 16:59:35 +0200, =?iso-8859-1?Q?J=F6rn?= Engel…
Plus the script is wrong sometimes. I have had trouble with sizes around 4G or 2G, and never found the time to really figure out what's going on. Might be an alloca thing that got misparsed somehow.
Quoted 6 lines
Quoted 3 lines
Some code results in negative adjustments to the stack size on exit, which look like 4G sizes. My script checks for those and ignores them. /^[89a-f].......$/d;
Ok, looks as if only my script is wrong. Do you know what exactly causes such a negative adjustment?
you can write "add 100,%esp" as "sub -100, %esp" :) compilers seem to do that at times, probably some cpu model inside the compiler decides the later is better code in some cases :)
Quoted 4 lines · Arjan van de Ven
you can write "add 100,%esp" as "sub -100, %esp" :) compilers seem to do that at times, probably some cpu model inside the compiler decides the later is better code in some cases :)
Makes sense (in a way). For x86 and ppc*, my script should be safe as a nice side effect:
qr/^.*sub \$(0x$x{3,5}),\%esp$/o
Anything above 5 digits is ignored. That also misses allocations above 1MB, but as long as human stupidity is finite... ;)
Jörn
Signature · 4 lines
ticks = jiffies; while (ticks == jiffies); ticks = jiffies; -- /usr/src/linux/init/main.c
Quoted 4 lines · Arjan van de Ven
you can write "add 100,%esp" as "sub -100, %esp" :) compilers seem to do that at times, probably some cpu model inside the compiler decides the later is better code in some cases :)
That and even worse things. sys_sendfile has a "sub $0x10,%esp" followed by an "add $0x20,%esp". Can you explain that one as well? 0x20 is the size of all automatic variables on i386.
I have no idea what kind of trick gcc is playing there, but it appears to work which makes me only more curious.
Jörn
Signature · 2 lines
Simplicity is prerequisite for reliability. -- Edsger W. Dijkstra