Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

context_tracking: Make RCU watch ct_kernel_exit_state() warning

The WARN_ON_ONCE() in ct_kernel_exit_state() follows the call to
ct_state_inc(), which means that RCU is not watching this WARN_ON_ONCE().
This can (and does) result in extraneous lockdep warnings when this
WARN_ON_ONCE() triggers. These extraneous warnings are the opposite
of helpful.

Therefore, invert the WARN_ON_ONCE() condition and move it before the
call to ct_state_inc(). This does mean that the ct_state_inc() return
value can no longer be used in the WARN_ON_ONCE() condition, so discard
this return value and instead use a call to rcu_is_watching_curr_cpu().
This call is executed only in CONFIG_RCU_EQS_DEBUG=y kernels, so there
is no added overhead in production use.

[Boqun: Add the subsystem tag in the title]

Reported-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Valentin Schneider <vschneid@redhat.com>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/r/bd911cd9-1fe9-447c-85e0-ea811a1dc896@paulmck-laptop
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>

authored by

Paul E. McKenney and committed by
Boqun Feng
59bed79f 69381f38

+4 -5
+4 -5
kernel/context_tracking.c
··· 80 80 */ 81 81 static noinstr void ct_kernel_exit_state(int offset) 82 82 { 83 - int seq; 84 - 85 83 /* 86 84 * CPUs seeing atomic_add_return() must see prior RCU read-side 87 85 * critical sections, and we also must force ordering with the 88 86 * next idle sojourn. 89 87 */ 90 88 rcu_task_trace_heavyweight_enter(); // Before CT state update! 91 - seq = ct_state_inc(offset); 92 - // RCU is no longer watching. Better be in extended quiescent state! 93 - WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && (seq & CT_RCU_WATCHING)); 89 + // RCU is still watching. Better not be in extended quiescent state! 90 + WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && !rcu_is_watching_curr_cpu()); 91 + (void)ct_state_inc(offset); 92 + // RCU is no longer watching. 94 93 } 95 94 96 95 /*