Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932914AbaDBSa0 (ORCPT ); Wed, 2 Apr 2014 14:30:26 -0400 Received: from mail-la0-f43.google.com ([209.85.215.43]:40276 "EHLO mail-la0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932487AbaDBSaY (ORCPT ); Wed, 2 Apr 2014 14:30:24 -0400 MIME-Version: 1.0 In-Reply-To: <20140402180513.GQ4284@linux.vnet.ibm.com> References: <1396455966-21128-1-git-send-email-fweisbec@gmail.com> <1396455966-21128-2-git-send-email-fweisbec@gmail.com> <20140402180513.GQ4284@linux.vnet.ibm.com> Date: Wed, 2 Apr 2014 20:30:23 +0200 Message-ID: Subject: Re: [PATCH 1/2] smp: Non busy-waiting IPI queue From: Frederic Weisbecker To: Paul McKenney Cc: Ingo Molnar , Thomas Gleixner , LKML , Andrew Morton , Jens Axboe , Kevin Hilman , Peter Zijlstra Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2014-04-02 20:05 GMT+02:00 Paul E. McKenney : > On Wed, Apr 02, 2014 at 06:26:05PM +0200, Frederic Weisbecker wrote: >> diff --git a/kernel/smp.c b/kernel/smp.c >> index 06d574e..bfe7b36 100644 >> --- a/kernel/smp.c >> +++ b/kernel/smp.c >> @@ -265,6 +265,50 @@ int smp_call_function_single_async(int cpu, struct call_single_data *csd) >> } >> EXPORT_SYMBOL_GPL(smp_call_function_single_async); >> >> +void generic_smp_queue_function_single_interrupt(void *info) >> +{ >> + struct queue_single_data *qsd = info; >> + >> + WARN_ON_ONCE(xchg(&qsd->pending, 0) != 1); > > I am probably missing something here, but shouldn't this function copy > *qsd to a local on-stack variable before doing the above xchg()? What > prevents the following from happening? > > o CPU 0 does smp_queue_function_single(), which sets ->pending > and fills in ->func and ->data. > > o CPU 1 takes IPI, invoking generic_smp_queue_function_single_interrupt(). > > o CPU 1 does xchg(), so that ->pending is now zero. > > o An attempt to reuse the queue_single_data sees ->pending equal > to zero, so the ->func and ->data is overwritten. > > o CPU 1 calls the new ->func with the new ->data (or any of the other > two possible unexpected outcomes), which might not be helpful to > the kernel's actuarial statistics. > > So what am I missing? Ah, I forgot to precise that the function must remain the same for all calls on a single qsd. And the data is always the qsd so this one can only stay stable. So that shouldn't be a problem. But you're right. The fact that we pass the function as an argument of smp_queue_function_single() suggests that we can pass a different function across various calls on a same qsd. So that's confusing. Perhaps changing smp_queue_function_single() such that it only takes the qsd as an argument would make that clearer? Then it's up to the caller to initialize the qsd with the constant function. I could define smp_queue_function_init() for that purpose. Or DEFINE_QUEUE_FUNCTION_DATA() for static initializers. How does that sound? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/