current_stack_pointeur() is a single instruction function. it
It is not worth breaking the execution flow with a bl/blr for a
single instruction
Signed-off-by: Christophe Leroy <redacted>
---
arch/powerpc/include/asm/reg.h | 7 ++++++-
arch/powerpc/kernel/misc.S | 4 ----
arch/powerpc/kernel/ppc_ksyms.c | 2 --
3 files changed, 6 insertions(+), 7 deletions(-)
Le 23/05/2016 à 22:22, Segher Boessenkool a écrit :
On Mon, May 23, 2016 at 10:46:02AM +0200, Christophe Leroy wrote:
quoted
+static inline unsigned long current_stack_pointer(void)
+{
+ register unsigned long *ptr asm("r1");
+
+ return *ptr;
+}
Register asm is only guaranteed to work as input to inline asm. NAK.
Does it mean that the following declaration in
arch/powerpc/include/asm/paca.h is wrong too ?
register struct paca_struct *local_paca asm("r13");
Christophe
From: Gabriel Paubert <hidden> Date: 2016-05-24 06:44:32
On Mon, May 23, 2016 at 10:46:02AM +0200, Christophe Leroy wrote:
current_stack_pointeur() is a single instruction function. it
It is not worth breaking the execution flow with a bl/blr for a
single instruction
Are you sure that the result is always the same?
Calling an external function prevents the compiler from considering the
caller of of current_stack_pointer a leaf function, which certainly
does not help the compiler, but in a leaf function the compiler is free
not to establish a new frame.
If the compiler decides to establishes a new frame (typically with
"stwu r1,-frame_size(r1)"), *r1 is the previous stack pointer, or
the caller's stack pointer, or the current function frame pointer if
I remember correctly the ABI definitions.
However, if the compiler decides that it can get away without a frame
for the function, *r1 is the stack pointer of the caller's caller.
Depending on the application, this may or may not be important.
By the way, isn't there a GCC builtin which can perform this task,
for example builtin_frame_address()?
Gabriel
From: Paul Mackerras <hidden> Date: 2016-05-25 03:40:23
On Mon, May 23, 2016 at 07:17:38PM +0200, Gabriel Paubert wrote:
On Mon, May 23, 2016 at 10:46:02AM +0200, Christophe Leroy wrote:
quoted
current_stack_pointeur() is a single instruction function. it
It is not worth breaking the execution flow with a bl/blr for a
single instruction
Are you sure that the result is always the same?
Calling an external function prevents the compiler from considering the
caller of of current_stack_pointer a leaf function, which certainly
does not help the compiler, but in a leaf function the compiler is free
not to establish a new frame.
If the compiler decides to establishes a new frame (typically with
"stwu r1,-frame_size(r1)"), *r1 is the previous stack pointer, or
the caller's stack pointer, or the current function frame pointer if
I remember correctly the ABI definitions.
However, if the compiler decides that it can get away without a frame
for the function, *r1 is the stack pointer of the caller's caller.
Depending on the application, this may or may not be important.
Right. I think I wrote the original current_stack_pointer()
implementation, and that I deliberately didn't make it an inline
so that the caller would have to establish its own stack frame,
and thus its stack pointer value would be a well-defined thing.
Paul.