* [PATCH -tip/core/rcu] Fix rcu_migrate_callback() to allow for multiple waiters
@ 2009-08-20 1:31 Paul E. McKenney
2009-08-20 3:30 ` Lai Jiangshan
0 siblings, 1 reply; 3+ messages in thread
From: Paul E. McKenney @ 2009-08-20 1:31 UTC (permalink / raw)
To: linux-kernel
Cc: mathieu.desnoyers, mingo, josht, laijs, dipankar, akpm, dvhltc,
niv, tglx, peterz, rostedt, hugh.dickins, benh
The current interaction between rcu_barrier() and CPU hotplug can result
in multiple tasks waiting on rcu_migrate_wq: there can be one CPU-hotplug
notifier, and, because rcu_barrier() invokes wait_migrated_callbacks()
outside of rcu_barrier_mutex, an arbitrarily large number of tasks
executing in _rcu_barrier(). This situation could result in hangs,
because rcu_migrate_callback() would wake up but one task.
This patch addresses this problem by awakening all sleepers.
Located-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
rcupdate.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
index bd5d5c8..6c59e1b 100644
--- a/kernel/rcupdate.c
+++ b/kernel/rcupdate.c
@@ -211,10 +211,17 @@ void rcu_barrier_sched(void)
}
EXPORT_SYMBOL_GPL(rcu_barrier_sched);
+/*
+ * Wake up anyone waiting on migration of RCU callbacks from a CPU
+ * going offline. There can be only one CPU-hotplug notifier waiting,
+ * but there can be any number of rcu_barrier() invocations waiting,
+ * due to the fact that rcu_barrier() does its wait outside of the
+ * rcu_barrier_mutex.
+ */
static void rcu_migrate_callback(struct rcu_head *notused)
{
if (atomic_dec_and_test(&rcu_migrate_type_count))
- wake_up(&rcu_migrate_wq);
+ wake_up_all(&rcu_migrate_wq);
}
extern int rcu_cpu_notify(struct notifier_block *self,
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH -tip/core/rcu] Fix rcu_migrate_callback() to allow for multiple waiters
2009-08-20 1:31 [PATCH -tip/core/rcu] Fix rcu_migrate_callback() to allow for multiple waiters Paul E. McKenney
@ 2009-08-20 3:30 ` Lai Jiangshan
2009-08-20 3:45 ` Paul E. McKenney
0 siblings, 1 reply; 3+ messages in thread
From: Lai Jiangshan @ 2009-08-20 3:30 UTC (permalink / raw)
To: paulmck
Cc: linux-kernel, mathieu.desnoyers, mingo, josht, dipankar, akpm,
dvhltc, niv, tglx, peterz, rostedt, hugh.dickins, benh
Paul E. McKenney wrote:
> The current interaction between rcu_barrier() and CPU hotplug can result
> in multiple tasks waiting on rcu_migrate_wq: there can be one CPU-hotplug
> notifier, and, because rcu_barrier() invokes wait_migrated_callbacks()
> outside of rcu_barrier_mutex, an arbitrarily large number of tasks
> executing in _rcu_barrier(). This situation could result in hangs,
> because rcu_migrate_callback() would wake up but one task.
>
> This patch addresses this problem by awakening all sleepers.
>
> Located-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> ---
>
> rcupdate.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
> index bd5d5c8..6c59e1b 100644
> --- a/kernel/rcupdate.c
> +++ b/kernel/rcupdate.c
> @@ -211,10 +211,17 @@ void rcu_barrier_sched(void)
> }
> EXPORT_SYMBOL_GPL(rcu_barrier_sched);
>
> +/*
> + * Wake up anyone waiting on migration of RCU callbacks from a CPU
> + * going offline. There can be only one CPU-hotplug notifier waiting,
> + * but there can be any number of rcu_barrier() invocations waiting,
> + * due to the fact that rcu_barrier() does its wait outside of the
> + * rcu_barrier_mutex.
> + */
> static void rcu_migrate_callback(struct rcu_head *notused)
> {
> if (atomic_dec_and_test(&rcu_migrate_type_count))
> - wake_up(&rcu_migrate_wq);
> + wake_up_all(&rcu_migrate_wq);
> }
>
> extern int rcu_cpu_notify(struct notifier_block *self,
>
Maybe wake_up_all() is good for readability. But wake_up()
is enough for the logic.
In wait_migrated_callbacks(), we use wait_event(), The current
thread is queued as a non-exclusive waiter. And wake_up()
wakes up all non-exclusive waiter. (We only have
non-exclusive waiters in the rcu_migrate_wq)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -tip/core/rcu] Fix rcu_migrate_callback() to allow for multiple waiters
2009-08-20 3:30 ` Lai Jiangshan
@ 2009-08-20 3:45 ` Paul E. McKenney
0 siblings, 0 replies; 3+ messages in thread
From: Paul E. McKenney @ 2009-08-20 3:45 UTC (permalink / raw)
To: Lai Jiangshan
Cc: linux-kernel, mathieu.desnoyers, mingo, josht, dipankar, akpm,
dvhltc, niv, tglx, peterz, rostedt, hugh.dickins, benh
On Thu, Aug 20, 2009 at 11:30:45AM +0800, Lai Jiangshan wrote:
> Paul E. McKenney wrote:
> > The current interaction between rcu_barrier() and CPU hotplug can result
> > in multiple tasks waiting on rcu_migrate_wq: there can be one CPU-hotplug
> > notifier, and, because rcu_barrier() invokes wait_migrated_callbacks()
> > outside of rcu_barrier_mutex, an arbitrarily large number of tasks
> > executing in _rcu_barrier(). This situation could result in hangs,
> > because rcu_migrate_callback() would wake up but one task.
> >
> > This patch addresses this problem by awakening all sleepers.
> >
> > Located-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > ---
> >
> > rcupdate.c | 9 ++++++++-
> > 1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
> > index bd5d5c8..6c59e1b 100644
> > --- a/kernel/rcupdate.c
> > +++ b/kernel/rcupdate.c
> > @@ -211,10 +211,17 @@ void rcu_barrier_sched(void)
> > }
> > EXPORT_SYMBOL_GPL(rcu_barrier_sched);
> >
> > +/*
> > + * Wake up anyone waiting on migration of RCU callbacks from a CPU
> > + * going offline. There can be only one CPU-hotplug notifier waiting,
> > + * but there can be any number of rcu_barrier() invocations waiting,
> > + * due to the fact that rcu_barrier() does its wait outside of the
> > + * rcu_barrier_mutex.
> > + */
> > static void rcu_migrate_callback(struct rcu_head *notused)
> > {
> > if (atomic_dec_and_test(&rcu_migrate_type_count))
> > - wake_up(&rcu_migrate_wq);
> > + wake_up_all(&rcu_migrate_wq);
> > }
> >
> > extern int rcu_cpu_notify(struct notifier_block *self,
> >
>
> Maybe wake_up_all() is good for readability. But wake_up()
> is enough for the logic.
>
> In wait_migrated_callbacks(), we use wait_event(), The current
> thread is queued as a non-exclusive waiter. And wake_up()
> wakes up all non-exclusive waiter. (We only have
> non-exclusive waiters in the rcu_migrate_wq)
And we even discussed this very point on March 18th!!!
OK, never mind, this patch has no effect.
Thanx, Paul
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-08-20 3:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-20 1:31 [PATCH -tip/core/rcu] Fix rcu_migrate_callback() to allow for multiple waiters Paul E. McKenney
2009-08-20 3:30 ` Lai Jiangshan
2009-08-20 3:45 ` Paul E. McKenney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).