mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shaohua Li <shaohua.li@intel.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: lkml <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
	Andi Kleen <andi@firstfloor.org>, "hpa@zytor.com" <hpa@zytor.com>
Subject: Re: [RFC 4/4]x86: avoid tlbstate lock if no enough cpus
Date: Wed, 03 Nov 2010 15:06:35 +0800	[thread overview]
Message-ID: <1288767995.23014.120.camel@sli10-conroe> (raw)
In-Reply-To: <1288767580.2467.636.camel@edumazet-laptop>

On Wed, 2010-11-03 at 14:59 +0800, Eric Dumazet wrote:
> Le mercredi 03 novembre 2010 à 14:44 +0800, Shaohua Li a écrit :
> > 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) {
> 
> Ouch, you remove a comment that pretty well explained the problem.
> 
> Last time I checked, num_online_cpus() was pretty expensive on a 4096
> cpus machine, since 4096 bits array is 512 bytes long.
ok
> Are you sure you didnt want to use nr_cpu_ids here ?
just don't want to include the non-present cpus here. I wonder why we
haven't a variable to record online cpu number.

Thanks,
Shaohua


  reply	other threads:[~2010-11-03  7:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-03  6:44 Shaohua Li
2010-11-03  6:59 ` Eric Dumazet
2010-11-03  7:06   ` Shaohua Li [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1288767995.23014.120.camel@sli10-conroe \
    --to=shaohua.li@intel.com \
    --cc=andi@firstfloor.org \
    --cc=eric.dumazet@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®