Skip to contentSkip to conversation

powerpc/mm/radix: Don't do page walk cache flush when doing full mm flush

PATCH Applied Aneesh Kumar K.V 3 participants 6 messages Apr 1, 2017 – Apr 10, 2017 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 powerpc/mm/radix: Don't do page walk cache flush when doing full mm flush

For fullmm tlb flush, we do a flush with RIC_FLUSH_ALL which will invalidate all related caches (radix__tlb_flush()). Hence the pwc flush is not needed.

---
 arch/powerpc/mm/tlb-radix.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/powerpc/mm/tlb-radix.c +12 -0
index 83dc1ccc2fa1..f3e58bd60d1a 100644
@@ -129,6 +129,12 @@ void radix__local_flush_tlb_pwc(struct mmu_gather *tlb, unsigned long addr)
 {
 	unsigned long pid;
 	struct mm_struct *mm = tlb->mm;
+	/*
+	 * If we are doing a full mm flush, we will do a tlb flush
+	 * with RIC_FLUSH_ALL later.
+	 */
+	if (tlb->fullmm)
+		return;
 
 	preempt_disable();
 
@@ -195,6 +201,12 @@ void radix__flush_tlb_pwc(struct mmu_gather *tlb, unsigned long addr)
 	unsigned long pid;
 	struct mm_struct *mm = tlb->mm;
 
+	/*
+	 * If we are doing a full mm flush, we will do a tlb flush
+	 * with RIC_FLUSH_ALL later.
+	 */
+	if (tlb->fullmm)
+		return;
 	preempt_disable();
 
 	pid = mm->context.id;
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 powerpc/mm/radix: Remove unnecessary ptesync

For a tlbiel with pid, we need to issue tlbiel with set number encoded. We don't need to do ptesync for each of those. Instead we need one for the entire tlbiel pid operation.

---
 arch/powerpc/mm/tlb-radix.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/mm/tlb-radix.c +2 -2
index f3e58bd60d1a..b68b5219cf45 100644
@@ -34,10 +34,8 @@ static inline void __tlbiel_pid(unsigned long pid, int set,
 	prs = 1; /* process scoped */
 	r = 1;   /* raidx format */
 
-	asm volatile("ptesync": : :"memory");
 	asm volatile(PPC_TLBIEL(%0, %4, %3, %2, %1)
 		     : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory");
-	asm volatile("ptesync": : :"memory");
 }
 
 /*
@@ -47,9 +45,11 @@ static inline void _tlbiel_pid(unsigned long pid, unsigned long ric)
 {
 	int set;
 
+	asm volatile("ptesync": : :"memory");
 	for (set = 0; set < POWER9_TLB_SETS_RADIX ; set++) {
 		__tlbiel_pid(pid, set, ric);
 	}
+	asm volatile("ptesync": : :"memory");
 	asm volatile(PPC_INVALIDATE_ERAT "; isync" : : :"memory");
 }
 
Signature · 1 line
2.7.4
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] powerpc/mm/radix: Remove unnecessary ptesync

Quoted 6 lines · On Sat, 1 Apr 2017 20:11:48 +0530 "Aneesh Kumar K.V"…

For a tlbiel with pid, we need to issue tlbiel with set number encoded. We don't need to do ptesync for each of those. Instead we need one for the entire tlbiel pid operation.

Thanks Aneesh.

Anton

Quoted 32 lines
---
 arch/powerpc/mm/tlb-radix.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/mm/tlb-radix.c +0 -0
index f3e58bd60d1a..b68b5219cf45 100644
@@ -34,10 +34,8 @@ static inline void __tlbiel_pid(unsigned long pid,

int set, prs = 1; /* process scoped */

arch/powerpc/mm/tlb-radix.c +0 -1
 	r = 1;   /* raidx format */
 
-	asm volatile("ptesync": : :"memory");
 	asm volatile(PPC_TLBIEL(%0, %4, %3, %2, %1)
 		     : : "r"(rb), "i"(r), "i"(prs), "i"(ric),

"r"(rs) : "memory");

arch/powerpc/mm/tlb-radix.c +2 -1
-	asm volatile("ptesync": : :"memory");
 }
 
 /*
@@ -47,9 +45,11 @@ static inline void _tlbiel_pid(unsigned long pid,
 unsigned long ric) {
 	int set;
 
+	asm volatile("ptesync": : :"memory");
 	for (set = 0; set < POWER9_TLB_SETS_RADIX ; set++) {
 		__tlbiel_pid(pid, set, ric);
 	}
+	asm volatile("ptesync": : :"memory");
 	asm volatile(PPC_INVALIDATE_ERAT "; isync" : : :"memory");
 }
 
#3 lore raw

Re: [2/2] powerpc/mm/radix: Remove unnecessary ptesync

In reply to Aneesh Kumar K.V
Quoted 7 lines · Aneesh Kumar K.V

For a tlbiel with pid, we need to issue tlbiel with set number encoded. We don't need to do ptesync for each of those. Instead we need one for the entire tlbiel pid operation.

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/f7327e0ba3805470cced2acfa053e7

cheers

Acked-by on v1 1/2
#4 lore raw
In reply to Aneesh Kumar K.V
Quoted 3 lines · On Sat, 1 Apr 2017 20:11:47 +0530 "Aneesh Kumar K.V"…

For fullmm tlb flush, we do a flush with RIC_FLUSH_ALL which will invalidate all related caches (radix__tlb_flush()). Hence the pwc flush is not needed.

Thanks Aneesh. I see a 3x improvement in exec performance with these 2 patches.

Anton

Quoted 36 lines
---
 arch/powerpc/mm/tlb-radix.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/powerpc/mm/tlb-radix.c +12 -0
index 83dc1ccc2fa1..f3e58bd60d1a 100644
@@ -129,6 +129,12 @@ void radix__local_flush_tlb_pwc(struct
 mmu_gather *tlb, unsigned long addr) {
 	unsigned long pid;
 	struct mm_struct *mm = tlb->mm;
+	/*
+	 * If we are doing a full mm flush, we will do a tlb flush
+	 * with RIC_FLUSH_ALL later.
+	 */
+	if (tlb->fullmm)
+		return;
 
 	preempt_disable();
 
@@ -195,6 +201,12 @@ void radix__flush_tlb_pwc(struct mmu_gather
 *tlb, unsigned long addr) unsigned long pid;
 	struct mm_struct *mm = tlb->mm;
 
+	/*
+	 * If we are doing a full mm flush, we will do a tlb flush
+	 * with RIC_FLUSH_ALL later.
+	 */
+	if (tlb->fullmm)
+		return;
 	preempt_disable();
 
 	pid = mm->context.id;