Re: [PATCH v5 20/22] powerpc/syscall: Avoid storing 'current' in another pointer
From: Nicholas Piggin
Date: Mon Feb 08 2021 - 21:38:00 EST
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@xxxxxxxxxx>
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 */
--