Re: switch_to()/doesnt %esp get replaced with %ebp on ret

Jamie Lokier (lk@tantalophile.demon.co.uk)
Tue, 20 Mar 2001 12:23:53 +0100


Parity Error wrote:
> I dont know if you understood my doubt, but your pointer
> to bp accidentally or otherwise solved the mystery.

We agree, and I like your explanation.

> Still, could some one enlighten me on why esi and edi are
> also similarly saved and restored ?

The compiler _may_ cache other values in those registers across the call
to switch_to. Although this doesn't happen in your kernel, it does
sometimes happen and switch_to must be coded to assume that it does.

You can safely remove the esi & edi pushes and pops, if you put those
registers in the "clobber" list of the asm. In theory that's best,
because then the compiler will save the register values itself only if
it needs to.

In practice, putting them in the clobber list sometimes results in worse
code, at least when I tried this in the 2.2 series.

You can't put ebp in the clobber list for some reason: GCC silently
ignores it. (Maybe that's fixed now too, I don't know).

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