Messages in this thread Patch in this message | | | Date | Tue, 09 Feb 2021 12:36:20 +1000 | From | Nicholas Piggin <> | Subject | Re: [PATCH v5 20/22] powerpc/syscall: Avoid storing 'current' in another pointer |
| |
Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: > By saving the pointer pointing to thread_info.flags, gcc copies r2 > in a non-volatile register. > > We know 'current' doesn't change, so avoid that intermediaite pointer. > > Reduces null_syscall benchmark by 2 cycles (322 => 320 cycles) > > On PPC64, gcc seems to know that 'current' is not changing, and it keeps > it in a non volatile register to avoid multiple read of 'current' in paca. > > Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
What if you did this?
--- arch/powerpc/include/asm/current.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/include/asm/current.h b/arch/powerpc/include/asm/current.h index bbfb94800415..59ab327972a5 100644 --- a/arch/powerpc/include/asm/current.h +++ b/arch/powerpc/include/asm/current.h @@ -23,16 +23,19 @@ static inline struct task_struct *get_current(void) return task; } -#define current get_current() #else -/* - * We keep `current' in r2 for speed. - */ -register struct task_struct *current asm ("r2"); +static inline struct task_struct *get_current(void) +{ + register struct task_struct *task asm ("r2"); + + return task; +} #endif +#define current get_current() + #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_CURRENT_H */ --
| |