Skip to content

Commit 0cae5de

Browse files
committed
rcu: Make RCU_LOCKDEP_WARN() avoid early lockdep checks
Currently, RCU_LOCKDEP_WARN() checks the condition before checking to see if lockdep is still enabled. This is necessary to avoid the false-positive splats fixed by commit 3066820 ("rcu: Reject RCU_LOCKDEP_WARN() false positives"). However, the current state can result in false-positive splats during early boot before lockdep is fully initialized. This commit therefore checks debug_lockdep_rcu_enabled() both before and after checking the condition, thus avoiding both sets of false-positive error reports. Reported-by: Steven Rostedt <[email protected]> Reported-by: Masami Hiramatsu (Google) <[email protected]> Reported-by: Mathieu Desnoyers <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]> Reviewed-by: Mathieu Desnoyers <[email protected]> Cc: Boqun Feng <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Thomas Gleixner <[email protected]>
1 parent 95ff24e commit 0cae5de

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

include/linux/rcupdate.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,18 @@ static inline int debug_lockdep_rcu_enabled(void)
374374
* RCU_LOCKDEP_WARN - emit lockdep splat if specified condition is met
375375
* @c: condition to check
376376
* @s: informative message
377+
*
378+
* This checks debug_lockdep_rcu_enabled() before checking (c) to
379+
* prevent early boot splats due to lockdep not yet being initialized,
380+
* and rechecks it after checking (c) to prevent false-positive splats
381+
* due to races with lockdep being disabled. See commit 3066820034b5dd
382+
* ("rcu: Reject RCU_LOCKDEP_WARN() false positives") for more detail.
377383
*/
378384
#define RCU_LOCKDEP_WARN(c, s) \
379385
do { \
380386
static bool __section(".data.unlikely") __warned; \
381-
if ((c) && debug_lockdep_rcu_enabled() && !__warned) { \
387+
if (debug_lockdep_rcu_enabled() && (c) && \
388+
debug_lockdep_rcu_enabled() && !__warned) { \
382389
__warned = true; \
383390
lockdep_rcu_suspicious(__FILE__, __LINE__, s); \
384391
} \

0 commit comments

Comments
 (0)