linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* rcu: Add might_sleep() check to synchronize_rcu()
@ 2018-03-23 21:12 Thomas Gleixner
  2018-03-23 21:28 ` Steven Rostedt
  2018-03-25 18:50 ` Paul E. McKenney
  0 siblings, 2 replies; 9+ messages in thread
From: Thomas Gleixner @ 2018-03-23 21:12 UTC (permalink / raw)
  To: LKML
  Cc: Paul E. McKenney, Peter Zijlstra, Josh Triplett, Steven Rostedt,
	Mathieu Desnoyers, Lai Jiangshan, Joel Fernandes

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-03-25 18:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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).