powerpc: No need to disable kernel FP/VMX/VSX MSR bits on context switch
PATCH 1/3 powerpc: No need to disable kernel FP/VMX/VSX MSR bits on context switch
There seems little point in disabling the FP/VMX/VSX MSR bits on context switch since we don't do it after calling enable_kernel_altivec() in other places. Writing the MSR is slow so lets not do it unnecessarily.
A context switch microbenchmark using yield():
http://ozlabs.org/~anton/junkcode/context_switch2.c
./context_switch2 --type=yield --fp 0 0
shows an improvement of almost 3% on POWER8.
--- arch/powerpc/kernel/entry_64.S | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
arch/powerpc/kernel/entry_64.S +1 -14
@@ -441,26 +441,13 @@ _GLOBAL(_switch) SAVE_8GPRS(14, r1) SAVE_10GPRS(22, r1) mflr r20 /* Return to switch caller */ - mfmsr r22 - li r0, MSR_FP -#ifdef CONFIG_VSX -BEGIN_FTR_SECTION - oris r0,r0,MSR_VSX@h /* Disable VSX */ -END_FTR_SECTION_IFSET(CPU_FTR_VSX) -#endif /* CONFIG_VSX */ #ifdef CONFIG_ALTIVEC BEGIN_FTR_SECTION - oris r0,r0,MSR_VEC@h /* Disable altivec */ mfspr r24,SPRN_VRSAVE /* save vrsave register value */ std r24,THREAD_VRSAVE(r3) END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) #endif /* CONFIG_ALTIVEC */ - and. r0,r0,r22 - beq+ 1f - andc r22,r22,r0 - MTMSRD(r22) - isync -1: std r20,_NIP(r1) + std r20,_NIP(r1) mfcr r23 std r23,_CCR(r1) std r1,KSP(r3) /* Set old stack pointer */
Signature · 1 line
2.1.4
PATCH 2/3 powerpc: Create context switch helpers save_sprs() and restore_sprs()
Move all our context switch SPR save and restore code into two helpers. We do a few optimisations:
- Group all mfsprs and all mtsprs. In many cases an mtspr sets a scoreboarding bit that an mfspr waits on, so the current practise of mfspr A; mtspr A; mfpsr B; mtspr B is the worst scheduling we can do.
- SPR writes are slow, so check that the value is changing before writing it.
A context switch microbenchmark using yield():
http://ozlabs.org/~anton/junkcode/context_switch2.c
./context_switch2 --type=yield 0 0
shows an improvement of almost 10% on POWER8.
--- arch/powerpc/include/asm/switch_to.h | 11 ----- arch/powerpc/kernel/entry_64.S | 60 +--------------------- arch/powerpc/kernel/process.c | 96 +++++++++++++++++++++++++++++++----- 3 files changed, 85 insertions(+), 82 deletions(-)
arch/powerpc/include/asm/switch_to.h +0 -11
@@ -15,17 +15,6 @@ extern struct task_struct *__switch_to(struct task_struct *,struct thread_struct ;extern struct task_struct *_switch (struct thread_struct *prev,struct thread_struct *next); -#ifdef CONFIG_PPC_BOOK3S_64 -static inline void save_early_sprs (struct thread_struct *prev) -{ -if (cpu_has_feature (CPU_FTR_ARCH_207S )) - prev->tar =mfspr (SPRN_TAR ); -if (cpu_has_feature (CPU_FTR_DSCR )) - prev->dscr =mfspr (SPRN_DSCR ); -} -#else -static inline void save_early_sprs (struct thread_struct *prev) {} -#endif extern void enable_kernel_fp (void );extern void enable_kernel_altivec (void );
arch/powerpc/kernel/entry_64.S +1 -59
77 lines not on this page · raw message
arch/powerpc/kernel/process.c +84 -12
132 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH 3/3 powerpc: Remove redundant mflr in _switch
In reply to Anton BlanchardNo need to execute mflr twice.
--- arch/powerpc/kernel/entry_64.S | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/powerpc/kernel/entry_64.S +1 -3
@@ -440,9 +440,7 @@ _GLOBAL(_switch) /* r3-r13 are caller saved -- Cort */ SAVE_8GPRS(14, r1) SAVE_10GPRS(22, r1) - mflr r20 /* Return to switch caller */ - - std r20,_NIP(r1) + std r0,_NIP(r1) /* Return to switch caller */ mfcr r23 std r23,_CCR(r1) std r1,KSP(r3) /* Set old stack pointer */
Signature · 1 line
2.1.4