Re: 2 switch_to() puzzles

Jamie Lokier (lkd@tantalophile.demon.co.uk)
Wed, 9 Dec 1998 16:59:12 +0000


On Tue, Dec 08, 1998 at 12:34:36AM +0100, MOLNAR Ingo wrote:
> On Mon, 7 Dec 1998, Project BRAVO wrote:
> > Why the switch_to() macro saves on the stack the values of
> > ebx, esi and edi (ebp is used by gcc because of the
> > -fno-omit-frame-pointer option) ?
>
> ebx, esi and edi have to be callee-saved on x86.
>
> > We tried the following patch (2.1.131) and it worked just fine.
>
> just by pure luck, switch_to() is at the end of schedule(), so esi and edi
> are not used later on. I guess you compiled the kernel on UP? If you
> compile the kernel as SMP sched.c already uses edi after the switch_to
> call ...

I think you'd get the best of all worlds by removing the push/pop
sequences (execpt %ebp), and declaring %ebx/%esi/%edi to be clobbered
registers.

Then the compiler will save them iff they need saving, and it looks like
they generally don't.

Last time I checked (GCC 2.7.2.1), declaring %ebp clobbered doesn't
cause GCC to save it even with -fomit-frame-pointer, so you need the
push/pop for that one.

Any objections?

-- Jamie

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