From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
LKML <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Jens Axboe <jens.axboe@oracle.com>,
Kevin Hilman <khilman@linaro.org>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH 1/2] smp: Non busy-waiting IPI queue
Date: Wed, 2 Apr 2014 12:01:08 -0700 [thread overview]
Message-ID: <20140402190108.GR4284@linux.vnet.ibm.com> (raw)
In-Reply-To: <CAFTL4hyUC7JO6+H4kiLCLOxO7WzyC+MUKxE-jrmanZMM4dXSrg@mail.gmail.com>
On Wed, Apr 02, 2014 at 08:30:23PM +0200, Frederic Weisbecker wrote:
> 2014-04-02 20:05 GMT+02:00 Paul E. McKenney <paulmck@linux.vnet.ibm.com>:
> > 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.
I did indeed miss that particular constraint. ;-)
> 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?
Sounds good!
Thanx, Paul
next prev parent reply other threads:[~2014-04-02 19:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-02 16:26 [GIT PULL] nohz: Move nohz kick out of scheduler IPI Frederic Weisbecker
2014-04-02 16:26 ` [PATCH 1/2] smp: Non busy-waiting IPI queue Frederic Weisbecker
2014-04-02 18:05 ` Paul E. McKenney
2014-04-02 18:30 ` Frederic Weisbecker
2014-04-02 19:01 ` Paul E. McKenney [this message]
2014-04-02 16:26 ` [PATCH 2/2] nohz: Move full nohz kick to its own IPI Frederic Weisbecker
-- strict thread matches above, loose matches on Subject: below --
2014-04-03 0:09 [PATCH 0/2] nohz: Move nohz kick out of scheduler IPI v2 Frederic Weisbecker
2014-04-03 0:09 ` [PATCH 1/2] smp: Non busy-waiting IPI queue Frederic Weisbecker
2014-04-03 16:17 [GIT PULL v2] nohz: Move nohz kick out of scheduler IPI Frederic Weisbecker
2014-04-03 16:17 ` [PATCH 1/2] smp: Non busy-waiting IPI queue Frederic Weisbecker
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=20140402190108.GR4284@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=jens.axboe@oracle.com \
--cc=khilman@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.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.