From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755909AbYCQTxS (ORCPT ); Mon, 17 Mar 2008 15:53:18 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753227AbYCQTxH (ORCPT ); Mon, 17 Mar 2008 15:53:07 -0400 Received: from brick.kernel.dk ([87.55.233.238]:15237 "EHLO kernel.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751646AbYCQTxG (ORCPT ); Mon, 17 Mar 2008 15:53:06 -0400 Date: Mon, 17 Mar 2008 20:53:01 +0100 From: Jens Axboe To: "Alan D. Brunelle" 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 Message-ID: <20080317195301.GL17940@kernel.dk> References: <47DE9E3F.7010600@hp.com> <20080317192615.GI17940@kernel.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080317192615.GI17940@kernel.dk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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