tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: zfs crash on amd64

On Sun 08 Nov 2009 at 21:03:09 +0000, David Laight wrote:
> no, -mno-red-zone

Aha. Interesting. For context I'll quote what the manpage has to say
about it:

           Do not use a so called red zone for x86-64 code.  The red zone is
           mandated by the x86-64 ABI, it is a 128-byte area beyond the loca-
           tion of the stack pointer that will not be modified by signal or
           interrupt handlers and therefore can be used for temporary data
           without adjusting the stack pointer.  The flag -mno-red-zone dis-
           ables this red zone.

Wasn't the name red zone already used for the bottom of the stack,
unmapped so it would trap and detect stack overflows? Or was that some
different colour? In any case, the name is confusing in this regard.

It seems to be an attempt to save on stack pointer adjustments when
calling functions. However, the compiler needs to do a full static
analysis of the call graph of the program to show that it can take
advantage of it. Otherwise, you'll never know if the local variables of
any particular function still fit in the magic 128 allotted bytes. And
since gcc compiles programs in modules, and the linker also isn't clever
enough to adjust for this sort of things at link time, it seems rather
useless to me. Maybe only for hand-written assembly. But who wants to
write in that crap sort of assembly language anyway? It's not VAX or
PDP-11 or even 680x0...

The example we've seen here also seems rather useless. It was a leaf
function with a big stack frame, which was allocated 128 bytes short,
using the red zone as a promise that it won't get clobbered. However,
such a construction absolutely requires interrupts to go on a separate
stack (unless hardware interrupt processing always first deducts 128
from the stack pointer before storing its interrupt frame??? No
apparently it doesn't since it fails inside the kernel).
And if this is done, there is no need to use the user stack anyway. So
the zone goes to waste. Furthermore, once you're adjusting a stack
pointer, there seems to be no point in not adjusting it the full size,
since the cost of adjusting it has already been taken.

>       David
___ Olaf 'Rhialto' Seibert    -- You author it, and I'll reader it.
\X/ rhialto/at/      -- Cetero censeo "authored" delendum esse.

Home | Main Index | Thread Index | Old Index