From: Peter Zijlstra <peterz@infradead.org>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Christoph Hellwig <hch@infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
John Stultz <john.stultz@linaro.org>,
Alex Shi <alex.shi@linaro.org>, Kevin Hilman <khilman@linaro.org>
Subject: Re: [PATCH 05/13] rcu: Fix unraised IPI to timekeeping CPU
Date: Wed, 18 Dec 2013 18:10:36 +0100 [thread overview]
Message-ID: <20131218171036.GW21999@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20131218153857.GF18464@localhost.localdomain>
On Wed, Dec 18, 2013 at 04:38:59PM +0100, Frederic Weisbecker wrote:
> BTW this warning in __smp_call_function_single() looks wrong:
>
> WARN_ON_ONCE(cpu_online(smp_processor_id()) && wait && irqs_disabled()
> && !oops_in_progress)
>
> I think we want to warn on irqs_disabled() even if !wait, because we wait for csd lock
> anyway before raising the IPI.
>
> Anyway so what I need is an IPI that can be raised with irqs disabled. And abusing the
> scheduler IPI with ugliness after the other is obsviously not what we want.
Ah indeed, so you can actually make it work but its a little more
involved.
struct foo {
struct call_single_data csd;
unsigned int msg;
};
static DEFINE_PER_CPU_ALIGNED(struct foo, foo_csd);
/*
* set @bit in @msg, return true if its the first bit set
*/
static bool foo_set_msg(unsigned int *msg, int bit)
{
unsigned int old_msg, new_msg;
for (;;) {
old_msg = new_msg = *msg;
new_msg |= 1U << bit;
if (cmpxchg(msg, old_msg, new_msg) == old_msg)
break;
}
return old_msg == 0;
}
/*
* clear @bit in @msg, return true if its the last bit cleared
*/
static bool foo_clear_msg(unsigned int *msg, int bit)
{
unsigned int old_msg, new_msg;
for (;;) {
old_msg = new_msg = *msg;
new_msg &= ~(1U << bit);
if (cmpxchg(msg, old_msg, new_msg) == old_msg)
break;
}
return new_msg == 0;
}
/*
* handle @bit msg
*/
static void foo_handle_msg(int bit)
{
switch (bit) {
case 0:
/* .... */
break;
/* ... */
}
}
static void foo_call(void *info)
{
struct foo *foo_csd = info;
int bit;
for (;;) {
for (bit = 0; bit < 32; bit++) {
if (ACCESS_ONCE(foo_csd->msg) & (1U << bit)) {
foo_handle_msg(bit);
if (foo_clear_msg(bit))
return;
}
}
}
}
int foo_init(void)
{
int cpu;
for_each_possible_cpu(cpu) {
struct foo *foo_csd = &per_cpu(foo_csd, cpu);
foo_csd->csd.flags = 0;
foo_csd->csd.func = foo_call;
foo_csd->csd.info = foo_csd;
foo_csd->msg = 0;
}
return 0;
}
void foo_msg(int cpu, int bit)
{
struct foo *foo_csd = &per_cpu(foo_csd, cpu);
/*
* Only send the IPI if this is the first msg bit set;
* otherwise the handler is already pending/running and
* will pick it up.
*
* This will not deadlock on csd_lock because the atomic
* msg manipulation ensures there's only ever one csd per cpu
* active.
*/
if (foo_set_msg(&foo_csd->msg, bit))
__smp_call_function_single(cpu, &foo_csd->csd, 0);
}
next prev parent reply other threads:[~2013-12-18 17:10 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-17 22:51 [RFC PATCH 00/13] nohz: Use sysidle detection to let the timekeeper sleep Frederic Weisbecker
2013-12-17 22:51 ` [PATCH 01/13] tick: Rename tick_check_idle() to tick_irq_enter() Frederic Weisbecker
2014-01-25 14:22 ` [tip:timers/urgent] " tip-bot for Frederic Weisbecker
2013-12-17 22:51 ` [PATCH 02/13] time: New helper to check CPU eligibility to handle timekeeping Frederic Weisbecker
2013-12-17 22:51 ` [PATCH 03/13] rcu: Exclude all potential timekeepers from sysidle detection Frederic Weisbecker
2013-12-17 23:27 ` Paul E. McKenney
2013-12-17 23:49 ` Frederic Weisbecker
2013-12-18 11:43 ` Peter Zijlstra
2013-12-18 11:46 ` Peter Zijlstra
2013-12-18 14:15 ` Paul E. McKenney
2013-12-18 16:24 ` Frederic Weisbecker
2013-12-17 22:51 ` [PATCH 04/13] tick: Use timekeeping_cpu() to elect the CPU handling timekeeping duty Frederic Weisbecker
2013-12-17 23:55 ` Paul E. McKenney
2013-12-17 22:51 ` [PATCH 05/13] rcu: Fix unraised IPI to timekeeping CPU Frederic Weisbecker
2013-12-17 23:21 ` Paul E. McKenney
2013-12-18 14:13 ` Frederic Weisbecker
2013-12-18 14:22 ` Paul E. McKenney
2013-12-18 14:56 ` Frederic Weisbecker
2013-12-18 15:11 ` Peter Zijlstra
2013-12-18 15:58 ` Frederic Weisbecker
2013-12-18 12:12 ` Peter Zijlstra
2013-12-18 15:38 ` Frederic Weisbecker
2013-12-18 15:45 ` Christoph Hellwig
2013-12-18 17:10 ` Peter Zijlstra [this message]
2013-12-17 22:51 ` [PATCH 06/13] nohz: Introduce full dynticks' default timekeeping target Frederic Weisbecker
2013-12-17 23:54 ` Paul E. McKenney
2013-12-17 22:51 ` [PATCH 07/13] sched: Enable IPI reception on timekeeper under nohz full system Frederic Weisbecker
2013-12-17 23:52 ` Paul E. McKenney
2013-12-18 14:49 ` Frederic Weisbecker
2013-12-18 15:50 ` Paul E. McKenney
2013-12-18 10:06 ` Peter Zijlstra
2013-12-17 22:51 ` [PATCH 08/13] nohz: Get timekeeping max deferment outside jiffies_lock Frederic Weisbecker
2014-01-25 14:22 ` [tip:timers/urgent] " tip-bot for Frederic Weisbecker
2013-12-17 22:51 ` [PATCH 09/13] nohz: Allow timekeeper's tick to stop when all full dynticks CPUs are idle Frederic Weisbecker
2013-12-17 23:51 ` Paul E. McKenney
2013-12-18 14:36 ` Frederic Weisbecker
2013-12-18 15:29 ` Paul E. McKenney
2013-12-17 22:51 ` [PATCH 10/13] nohz: Hand over timekeeping duty on cpu offlining Frederic Weisbecker
2013-12-17 23:40 ` Paul E. McKenney
2013-12-18 14:19 ` Frederic Weisbecker
2013-12-18 12:30 ` Peter Zijlstra
2013-12-18 16:43 ` Frederic Weisbecker
2013-12-17 22:51 ` [PATCH 11/13] nohz: Wake up timekeeper on exit from sysidle state Frederic Weisbecker
2013-12-17 23:34 ` Paul E. McKenney
2013-12-17 23:52 ` Frederic Weisbecker
2013-12-17 22:51 ` [PATCH 12/13] nohz: Allow all CPUs outside nohz_full range to do timekeeping Frederic Weisbecker
2013-12-17 23:32 ` Paul E. McKenney
2013-12-17 22:51 ` [PATCH 13/13] nohz_full: fix code style issue of tick_nohz_full_stop_tick Frederic Weisbecker
2013-12-18 2:04 ` [RFC PATCH 00/13] nohz: Use sysidle detection to let the timekeeper sleep Alex Shi
2013-12-18 10:19 ` Peter Zijlstra
2013-12-18 14:18 ` Paul E. McKenney
2013-12-18 17:43 ` Frederic Weisbecker
2013-12-18 21:29 ` Andy Lutomirski
2013-12-18 21:49 ` Paul E. McKenney
2013-12-18 21:53 ` Andy Lutomirski
2013-12-18 21:57 ` Paul E. McKenney
2013-12-18 22:55 ` Andy Lutomirski
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=20131218171036.GW21999@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=alex.shi@linaro.org \
--cc=fweisbec@gmail.com \
--cc=hch@infradead.org \
--cc=john.stultz@linaro.org \
--cc=khilman@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rostedt@goodmis.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox