powerpc/mm/radix: Optimize tlbiel flush
RFC PATCH 1/1 powerpc/mm/radix: Optimize tlbiel flush
For a page walk cache flush, we don't need to loop with set number. The set number is ignored with RIC=1 (pwc flush).
For RIC=2 (flush all), inorder to flush implementation dependent caches, we can ignore the set number. Hence we do a RIC=2 flush with set no: 0, so we do both the tlb flush for set 0 and the implementation dependent cache flushes. This is then followed with tbl flush for set 1-127
---
Note: not yet tested.
arch/powerpc/mm/tlb-radix.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)
arch/powerpc/mm/tlb-radix.c +23 -5
@@ -43,12 +43,30 @@ static inline void __tlbiel_pid(unsigned long pid, int set,*/ static inline void _tlbiel_pid (unsigned long pid,unsigned long ric) { -int set; +int set =0 ; asmvolatile ("ptesync" : : :"memory" ); -for (set =0 ; set <POWER9_TLB_SETS_RADIX ; set++) { -__tlbiel_pid (pid, set, ric); +if (ric ==RIC_FLUSH_ALL ) { + ric =RIC_FLUSH_TLB ; + set =1 ; +/* Use set 0 to flush all */ +__tlbiel_pid (pid,0 ,RIC_FLUSH_ALL ); } + +for (; set <POWER9_TLB_SETS_RADIX ; set++) +__tlbiel_pid (pid, set, ric); + + asmvolatile ("ptesync" : : :"memory" ); + asmvolatile (PPC_INVALIDATE_ERAT "; isync" : : :"memory" ); +} + +static inline void _tlbiel_pwc (unsigned long pid) +{ + asmvolatile ("ptesync" : : :"memory" ); +/* +* for PWC flush, we don't look at set number +*/ +__tlbiel_pid (pid,0 ,RIC_FLUSH_PWC ); asmvolatile ("ptesync" : : :"memory" ); asmvolatile (PPC_INVALIDATE_ERAT "; isync" : : :"memory" ); }
@@ -140,7 +158,7 @@ void radix__local_flush_tlb_pwc(struct mmu_gather *tlb, unsigned long addr) pid = mm->context.id;if (pid !=MMU_NO_CONTEXT ) -_tlbiel_pid (pid,RIC_FLUSH_PWC ); +_tlbiel_pwc (pid);preempt_enable (); }
@@ -222,7 +240,7 @@ void radix__flush_tlb_pwc(struct mmu_gather *tlb, unsigned long addr)if (lock_tlbie)raw_spin_unlock (&native_tlbie_lock); }else -_tlbiel_pid (pid,RIC_FLUSH_PWC ); +_tlbiel_pwc (pid); no_context:preempt_enable (); }
Signature · 1 line
2.7.4
Hi Aneesh,
Quoted 8 lines
For a page walk cache flush, we don't need to loop with set number. The set number is ignored with RIC=1 (pwc flush).
For RIC=2 (flush all), inorder to flush implementation dependent caches, we can ignore the set number. Hence we do a RIC=2 flush with set no: 0, so we do both the tlb flush for set 0 and the implementation dependent cache flushes. This is then followed with tbl flush for set 1-127
I've applied your two previous radix tlbiel optimisations as my baseline, and using the simple exec microbenchmark in a7a9dcd882a6 I see:
HPT: 100% Radix baseline: 248% Radix patched: 95%
So this patch fixes the large regression we see with radix, and is even faster than our HPT number now. Nice work!
Anton
Quoted 63 lines
Signed-off-by Aneesh Kumar K.V <[email protected]>---
Note: not yet tested.arch/powerpc/mm/tlb-radix.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)arch/powerpc/mm/tlb-radix.c +0
-0@@ -43,12 +43,30 @@ static inline void __tlbiel_pid(unsigned longpid, int set, */
static inline void_tlbiel_pid(unsigned long pid, unsigned long ric){arch/powerpc/mm/tlb-radix.c +23
-5-int set; +int set =0 ; asmvolatile ("ptesync" : : :"memory" ); -for (set =0 ; set <POWER9_TLB_SETS_RADIX ; set++) { -__tlbiel_pid (pid, set, ric); +if (ric ==RIC_FLUSH_ALL ) { + ric =RIC_FLUSH_TLB ; + set =1 ; +/* Use set 0 to flush all */ +__tlbiel_pid (pid,0 ,RIC_FLUSH_ALL ); } + +for (; set <POWER9_TLB_SETS_RADIX ; set++) +__tlbiel_pid (pid, set, ric); + + asmvolatile ("ptesync" : : :"memory" ); + asmvolatile (PPC_INVALIDATE_ERAT "; isync" : : :"memory" ); +} + +static inline void _tlbiel_pwc (unsigned long pid) +{ + asmvolatile ("ptesync" : : :"memory" ); +/* +* for PWC flush, we don't look at set number +*/ +__tlbiel_pid (pid,0 ,RIC_FLUSH_PWC ); asmvolatile ("ptesync" : : :"memory" ); asmvolatile (PPC_INVALIDATE_ERAT "; isync" : : :"memory" ); }@@ -140,7 +158,7 @@ void radix__local_flush_tlb_pwc(struct mmu_gather *tlb, unsigned long addr) pid = mm->context.id;if (pid !=MMU_NO_CONTEXT ) -_tlbiel_pid (pid,RIC_FLUSH_PWC ); +_tlbiel_pwc (pid);preempt_enable (); }@@ -222,7 +240,7 @@ void radix__flush_tlb_pwc(struct mmu_gather *tlb, unsigned long addr) if (lock_tlbie)raw_spin_unlock (&native_tlbie_lock); }else -_tlbiel_pid (pid,RIC_FLUSH_PWC ); +_tlbiel_pwc (pid); no_context:preempt_enable (); }