Skip to contentSkip to conversation

powerpc/64s: optimise syscall entry for virtual, relocatable case

PATCH Applied Nicholas Piggin 3 participants 3 messages Sep 15, 2016 – Sep 20, 2016 PowerPC

lore
Share & tools
lore

Nicholas Piggin

author reviewer
#0 lore raw

PATCH 1/1 powerpc/64s: optimise syscall entry for virtual, relocatable case

The mflr r10 instruction was left over saving of lr when the code used lr to branch to system_call_entry from the exception handler. That was changed by 6a404806d to use the count register. The value is never used now, so mflr can be removed, and r10 can be used for storage rather than spilling to the SPR scratch register.

The scratch register spill causes a long pipeline stall due to the SPR read after write. This change brings getppid syscall cost from 406 to 376 cycles on POWER8. getppid for non-relocatable case is 371 cycles.

---

 arch/powerpc/kernel/exceptions-64s.S | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
arch/powerpc/kernel/exceptions-64s.S +2 -5
index df6d45e..2cdd64f 100644
@@ -63,15 +63,12 @@ END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)				\
 	 * is volatile across system calls.
 	 */
 #define SYSCALL_PSERIES_2_DIRECT				\
-	mflr	r10 ;						\
 	ld	r12,PACAKBASE(r13) ; 				\
 	LOAD_HANDLER(r12, system_call_entry) ;			\
 	mtctr	r12 ;						\
 	mfspr	r12,SPRN_SRR1 ;					\
-	/* Re-use of r13... No spare regs to do this */	\
-	li	r13,MSR_RI ;					\
-	mtmsrd 	r13,1 ;						\
-	GET_PACA(r13) ;	/* get r13 back */			\
+	li	r10,MSR_RI ;					\
+	mtmsrd 	r10,1 ;						\
 	bctr ;
 #else
 	/* We can branch directly */
Signature · 1 line
2.9.3
Acked-by on v1 1/1
#1 lore raw
Quoted 29 lines · Nicholas Piggin

The mflr r10 instruction was left over saving of lr when the code used lr to branch to system_call_entry from the exception handler. That was changed by 6a404806d to use the count register. The value is never used now, so mflr can be removed, and r10 can be used for storage rather than spilling to the SPR scratch register.

The scratch register spill causes a long pipeline stall due to the SPR read after write. This change brings getppid syscall cost from 406 to 376 cycles on POWER8. getppid for non-relocatable case is 371 cycles.

---

 arch/powerpc/kernel/exceptions-64s.S | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
arch/powerpc/kernel/exceptions-64s.S +0 -1
index df6d45e..2cdd64f 100644
@@ -63,15 +63,12 @@ END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)				\
 	 * is volatile across system calls.
 	 */
 #define SYSCALL_PSERIES_2_DIRECT				\
-	mflr	r10 ;						\
 	ld	r12,PACAKBASE(r13) ; 				\
 	LOAD_HANDLER(r12, system_call_entry) ;			\
 	mtctr	r12 ;						\

arch/powerpc/kernel/exceptions-64s.S END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) \ · line 74

Quoted 10 lines
arch/powerpc/kernel/exceptions-64s.S +2 -4
 	mfspr	r12,SPRN_SRR1 ;					\
-	/* Re-use of r13... No spare regs to do this */	\
-	li	r13,MSR_RI ;					\
-	mtmsrd 	r13,1 ;						\
-	GET_PACA(r13) ;	/* get r13 back */			\
+	li	r10,MSR_RI ;					\
+	mtmsrd 	r10,1 ;						\
 	bctr ;
 #else
 	/* We can branch directly */

The patch makes sense

#2 lore raw
In reply to Nicholas Piggin
Quoted 6 lines · Nicholas Piggin

The mflr r10 instruction was left over saving of lr when the code used lr to branch to system_call_entry from the exception handler. That was changed by 6a404806d to use the count register. The value is never used now, so mflr can be removed, and r10 can be used for storage rather than spilling to the SPR scratch register.

Quoted 6 lines

The scratch register spill causes a long pipeline stall due to the SPR read after write. This change brings getppid syscall cost from 406 to 376 cycles on POWER8. getppid for non-relocatable case is 371 cycles.

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/18e3f56b1cacb96017e2a66844

cheers