Skip to contentSkip to conversation

Avoid double flush in do_tlb_flush_all()

PATCH In review Andi Kleen 2 participants 2 messages Aug 30, 2008 x86

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 Avoid double flush in do_tlb_flush_all()

Avoid double flush in do_tlb_flush_all()

leave_mm already flushes the TLBs, so don't need to flush directly before that in do_flush_tlb_all(). Avoid the double flush.

Pointed out by Rainer Weikusat

---
 arch/x86/kernel/tlb_32.c |    5 ++---
 arch/x86/kernel/tlb_64.c |    7 +++----
 2 files changed, 5 insertions(+), 7 deletions(-)
arch/x86/kernel/tlb_32.c +2 -3
Index: linux-2.6.27-rc4-misc/arch/x86/kernel/tlb_32.c
===================================================================
@@ -229,11 +229,10 @@ EXPORT_SYMBOL(flush_tlb_page);
 
 static void do_flush_tlb_all(void *info)
 {
-	unsigned long cpu = smp_processor_id();
-
-	__flush_tlb_all();
 	if (per_cpu(cpu_tlbstate, cpu).state == TLBSTATE_LAZY)
 		leave_mm(cpu);
+	else
+		__flush_tlb_all(smp_processor_id());
 }
 
 void flush_tlb_all(void)
arch/x86/kernel/tlb_64.c +3 -4
Index: linux-2.6.27-rc4-misc/arch/x86/kernel/tlb_64.c
===================================================================
@@ -266,11 +266,10 @@ void flush_tlb_page(struct vm_area_struc
 
 static void do_flush_tlb_all(void *info)
 {
-	unsigned long cpu = smp_processor_id();
-
-	__flush_tlb_all();
 	if (read_pda(mmu_state) == TLBSTATE_LAZY)
-		leave_mm(cpu);
+		leave_mm(smp_processor_id());
+	else
+		__flush_tlb_all();
 }
 
 void flush_tlb_all(void)
#1 lore raw
Quoted 4 lines · On Sat, 30 Aug 2008 12:20:12 +0200 Andi Kleen <[email protected]> wrote:

Avoid double flush in do_tlb_flush_all()

leave_mm already flushes the TLBs, so don't need to flush directly before that in do_flush_tlb_all(). Avoid the double flush.

but... the leave_mm won't flush the global tlbs, while __flush_tlb_all() does, right?

sounds like we do need the behavior