Re: [PATCH] powerpc/irq: don't use current_stack_pointer() in do_IRQ()
From: Christophe Leroy
Date: Thu Dec 12 2019 - 11:29:09 EST
Le 12/12/2019 Ã 13:51, Christoph Hellwig a ÃcritÂ:
Why can't current_stack_pointer be turned into an inline function using
inline assembly? That would reduce the overhead for all callers.
In the old days, it was a macro, and it was changed into an assembly
function by commit
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bfe9a2cfe91a
It was later renamed from __get_SP() to current_stack_pointer() by
commit
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=acf620ecf56cfc4edaffaf158250e128539cdd26
But in fact this function is badly named as it doesn't provide the
current stack pointer but a pointer to the parent's stack frame.
Having it as an extern function forces GCC to set a stack frame in the
calling function. If inline assembly is used instead, there's a risk of
not getting a stack frame in the calling function, in which case the
current_stack_pointer() will return the grandparent's stackframe pointer
instead of the parent's one.
Christophe