mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC 4/4]x86: avoid tlbstate lock if no enough cpus
@ 2010-11-03  6:44 Shaohua Li
  2010-11-03  6:59 ` Eric Dumazet
  0 siblings, 1 reply; 10+ messages in thread
From: Shaohua Li @ 2010-11-03  6:44 UTC (permalink / raw)
  To: lkml; +Cc: Ingo Molnar, Andi Kleen, hpa

This one isn't related to previous patch. If online cpus are below
NUM_INVALIDATE_TLB_VECTORS, we don't need the lock. The comments
in the code declares we don't need the check, but a hot lock still
needs an atomic operation and expensive, so add the check here.

Signed-off-by: Shaohua Li <shaohua.li@intel.com>
---
 arch/x86/mm/tlb.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Index: linux/arch/x86/mm/tlb.c
===================================================================
--- linux.orig/arch/x86/mm/tlb.c	2010-11-02 10:31:51.000000000 +0800
+++ linux/arch/x86/mm/tlb.c	2010-11-02 14:53:27.000000000 +0800
@@ -174,17 +174,16 @@ static void flush_tlb_others_ipi(const s
 {
 	unsigned int sender;
 	union smp_flush_state *f;
+	bool do_lock = false;
 
 	/* Caller has disabled preemption */
 	sender = this_cpu_read(tlb_vector_offset);
 	f = &flush_state[sender];
 
-	/*
-	 * Could avoid this lock when
-	 * num_online_cpus() <= NUM_INVALIDATE_TLB_VECTORS, but it is
-	 * probably not worth checking this for a cache-hot lock.
-	 */
-	raw_spin_lock(&f->tlbstate_lock);
+	if (num_online_cpus() > NUM_INVALIDATE_TLB_VECTORS) {
+		do_lock = true;
+		raw_spin_lock(&f->tlbstate_lock);
+	}
 
 	f->flush_mm = mm;
 	f->flush_va = va;
@@ -202,7 +201,8 @@ static void flush_tlb_others_ipi(const s
 
 	f->flush_mm = NULL;
 	f->flush_va = 0;
-	raw_spin_unlock(&f->tlbstate_lock);
+	if (do_lock)
+		raw_spin_unlock(&f->tlbstate_lock);
 }
 
 void native_flush_tlb_others(const struct cpumask *cpumask,



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-11-04  5:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-03  6:44 [RFC 4/4]x86: avoid tlbstate lock if no enough cpus Shaohua Li
2010-11-03  6:59 ` Eric Dumazet
2010-11-03  7:06   ` Shaohua Li
2010-11-03  7:12     ` Eric Dumazet
2010-11-03  7:19       ` Shaohua Li
2010-11-03  7:25         ` Eric Dumazet
2010-11-03  7:31           ` Eric Dumazet
     [not found]             ` <1288773716.23014.124.camel@sli10-conroe>
2010-11-03  9:08               ` Eric Dumazet
2010-11-04  5:21                 ` Shaohua Li
2010-11-04  5:42                   ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®