From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Josh Triplett <josh@joshtriplett.org>,
Steven Rostedt <rostedt@goodmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Joel Fernandes <joelaf@google.com>
Subject: Re: rcu: Add might_sleep() check to synchronize_rcu()
Date: Sun, 25 Mar 2018 11:50:26 -0700 [thread overview]
Message-ID: <20180325185026.GF3675@linux.vnet.ibm.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1803232210110.1481@nanos.tec.linutronix.de>
On Fri, Mar 23, 2018 at 10:12:24PM +0100, Thomas Gleixner wrote:
> Subject: rcu: Add might_sleep() check to synchronize_rcu()
> From: Thomas Gleixner <tglx@linutronix.de>
> Date: Fri, 23 Mar 2018 22:02:18 +0100
>
> Joel reported a debugobjects warning which is triggered by a RCU callback
> invoking synchronize_rcu(). RCU callbacks run in softirq context, so
> calling synchronize_rcu() is a bad idea as it might sleep.
>
> debugobjects triggers because __wait_rcu_gp() uses on stack objects and
> invokes debug_object_init_on_stack(). That function checks the object
> address against current's task stack, which fails because the code runs on
> the softirq stack.
>
> synchronize_rcu() lacks a might_sleep() check which would have caught that
> issue way earlier because it would trigger with the minimal debug options
> enabled.
>
> Add a might_sleep() check to catch such cases.
>
> Reported-by: Joel Fernandes <joelaf@google.com>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
> Cc: Josh Triplett <josh@joshtriplett.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> Cc: Lai Jiangshan <jiangshanlai@gmail.com>
> ---
> kernel/rcu/tree_plugin.h | 1 +
> 1 file changed, 1 insertion(+)
>
> --- a/kernel/rcu/tree_plugin.h
> +++ b/kernel/rcu/tree_plugin.h
> @@ -753,6 +753,7 @@ void synchronize_rcu(void)
> "Illegal synchronize_rcu() in RCU read-side critical section");
> if (rcu_scheduler_active == RCU_SCHEDULER_INACTIVE)
> return;
> + might_sleep();
> if (rcu_gp_is_expedited())
> synchronize_rcu_expedited();
> else
I could add this, but synchronize_rcu_expedited() will do
either a mutex_lock() or a wait_event(), both of which already
have a might_sleep(), and wait_rcu_gp() unconditionally calls
wait_for_completion(), which already has a might_sleep().
Unless there is only one CPU in the system either at early boot. Is
this possibility common enough to warrant a might_sleep() further up?
Thanx, Paul
prev parent reply other threads:[~2018-03-25 18:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-23 21:12 rcu: Add might_sleep() check to synchronize_rcu() Thomas Gleixner
2018-03-23 21:28 ` Steven Rostedt
2018-03-23 21:33 ` Thomas Gleixner
2018-03-23 21:40 ` Steven Rostedt
2018-03-23 21:46 ` Thomas Gleixner
2018-03-23 22:57 ` Joel Fernandes
2018-03-24 1:21 ` Steven Rostedt
2018-03-25 18:43 ` Paul E. McKenney
2018-03-25 18:50 ` Paul E. McKenney [this message]
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=20180325185026.GF3675@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=jiangshanlai@gmail.com \
--cc=joelaf@google.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=peterz@infradead.org \
--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 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.