All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: "Alan D. Brunelle" <Alan.Brunelle@hp.com>
Cc: linux-kernel@vger.kernel.org, npiggin@suse.de, dgc@sgi.com
Subject: Re: [Patch (block.git) 2/2] Ensure single IPI generation for SMP call  single
Date: Mon, 17 Mar 2008 20:53:01 +0100	[thread overview]
Message-ID: <20080317195301.GL17940@kernel.dk> (raw)
In-Reply-To: <20080317192615.GI17940@kernel.dk>

On Mon, Mar 17 2008, Jens Axboe wrote:
> On Mon, Mar 17 2008, Alan D. Brunelle wrote:
> > diff --git a/kernel/smp.c b/kernel/smp.c
> > index 7232e1c..f7ec401 100644
> > --- a/kernel/smp.c
> > +++ b/kernel/smp.c
> > @@ -23,28 +23,34 @@ void __cpuinit generic_init_call_single_data(void)
> >  
> >  void generic_smp_call_function_single_interrupt(void)
> >  {
> > -	struct call_single_queue *q;
> >  	unsigned long flags;
> >  	LIST_HEAD(list);
> > +	struct call_single_queue *q = &__get_cpu_var(call_single_queue);
> >  
> > -	q = &__get_cpu_var(call_single_queue);
> >  	spin_lock_irqsave(&q->lock, flags);
> > -	list_replace_init(&q->list, &list);
> > -	spin_unlock_irqrestore(&q->lock, flags);
> > +	while (!list_empty(&q->list)) {
> > +		list_replace_init(&q->list, &list);
> > +		spin_unlock_irqrestore(&q->lock, flags);
> >  
> > -	while (!list_empty(&list)) {
> > -		struct call_single_data *data;
> > +		do {
> > +			struct call_single_data *data;
> >  
> > -		data = list_entry(list.next, struct call_single_data, list);
> > -		list_del(&data->list);
> > +			data = list_entry(list.next, struct call_single_data,
> > +						list);
> > +			list_del(&data->list);
> >  
> > -		data->func(data->info);
> > -		if (data->flags & CSD_FLAG_WAIT) {
> > -			smp_wmb();
> > -			data->flags = 0;
> > -		} else if (data->flags & CSD_FLAG_ALLOC)
> > -			kfree(data);
> > +			data->func(data->info);
> > +			if (data->flags & CSD_FLAG_WAIT) {
> > +				smp_wmb();
> > +				data->flags = 0;
> > +			} else if (data->flags & CSD_FLAG_ALLOC)
> > +				kfree(data);
> > +		} while (!list_empty(&list));
> > +
> > +		spin_lock_irqsave(&q->lock, flags);
> >  	}
> > +	q->activated = 0;
> > +	spin_unlock_irqrestore(&q->lock, flags);
> >  }
> 
> I agree with doing it this way, re-checking and doing another run (or
> more). However I think we can improve it a bit so we don't always have
> to grab the dst lock at least twice - it should be safe enough to
> include the lock only inside the first loop, doing an smp_mb() before
> the list_empty() check and again at the bottom before looping around and
> doing the list_empty() check again.
> 
> I've rolled a new patch series here:
> 
> http://git.kernel.dk/?p=linux-2.6-block.git;a=shortlog;h=io-cpu-affinity
> 
> (or just pull the io-cpu-affinity branch), it also includes a bunch of
> other cleanups like porting the faster smp_call_function() to ia64 and
> powerpc as well. So the kernel/smp.c generic helpers have grown a bit,
> while the arch bits are smaller.
> 
> I'm curious if it now boots on ia64, since I killed the hack to manually
> call the __init manually there. If you could check, I would appreciate
> it ;-)
> 
> I've built all 4 supported archs and they compile and link fine, but
> nothing has been booted yet.

x86 and x86-64 boot just fine, so powerpc should work as well (will do
performance testing on a 4-way ppc tomorrow). ia64 should also work, as
long as the init_call_single_data() gets called correctly.

If it doesn't work on tha ia64, try and change the core_initcall() to a
postcore_initcall() or even an arch_initcall(). It now resides in
kernel/smp.c.

-- 
Jens Axboe


      reply	other threads:[~2008-03-17 19:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-17 16:37 [Patch (block.git) 2/2] Ensure single IPI generation for SMP call single Alan D. Brunelle
2008-03-17 19:26 ` Jens Axboe
2008-03-17 19:53   ` Jens Axboe [this message]

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=20080317195301.GL17940@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=Alan.Brunelle@hp.com \
    --cc=dgc@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npiggin@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.