Skip to content

Commit

Permalink
x86: Avoid tlbstate lock if not enough cpus
Browse files Browse the repository at this point in the history
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.

Uses nr_cpu_ids here as suggested by Eric Dumazet.

Signed-off-by: Shaohua Li <shaohua.li@intel.com>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Andi Kleen <andi@firstfloor.org>
LKML-Reference: <1295232730.1949.710.camel@sli10-conroe>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Shaohua Li authored and Ingo Molnar committed Feb 14, 2011
1 parent 70e4a36 commit 7064d86
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions arch/x86/mm/tlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,8 @@ static void flush_tlb_others_ipi(const struct cpumask *cpumask,
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 (nr_cpu_ids > NUM_INVALIDATE_TLB_VECTORS)
raw_spin_lock(&f->tlbstate_lock);

f->flush_mm = mm;
f->flush_va = va;
Expand All @@ -202,7 +198,8 @@ static void flush_tlb_others_ipi(const struct cpumask *cpumask,

f->flush_mm = NULL;
f->flush_va = 0;
raw_spin_unlock(&f->tlbstate_lock);
if (nr_cpu_ids > NUM_INVALIDATE_TLB_VECTORS)
raw_spin_unlock(&f->tlbstate_lock);
}

void native_flush_tlb_others(const struct cpumask *cpumask,
Expand Down

0 comments on commit 7064d86

Please sign in to comment.