From: Boqun Feng <boqun.feng@gmail.com>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com, rostedt@goodmis.org, leitao@debian.org,
vschneid@redhat.com, frederic@kernel.org
Subject: Re: [PATCH rcu 6/5] Make RCU watch ct_kernel_exit_state() warning
Date: Thu, 6 Feb 2025 09:38:04 -0800 [thread overview]
Message-ID: <Z6TzfG4UZyKcpRzB@Mac.home> (raw)
In-Reply-To: <bd911cd9-1fe9-447c-85e0-ea811a1dc896@paulmck-laptop>
On Thu, Feb 06, 2025 at 02:15:09AM -0800, Paul E. McKenney wrote:
> 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.
>
> 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>
>
Queued at:
git://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux.git misc.2025.02.06a
I added the "context_tracking:" tag to the title while I'm at it.
Regards,
Boqun
> diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c
> index 938c48952d26..fb5be6e9b423 100644
> --- a/kernel/context_tracking.c
> +++ b/kernel/context_tracking.c
> @@ -80,17 +80,16 @@ static __always_inline void rcu_task_trace_heavyweight_exit(void)
> */
> static noinstr void ct_kernel_exit_state(int offset)
> {
> - int seq;
> -
> /*
> * CPUs seeing atomic_add_return() must see prior RCU read-side
> * critical sections, and we also must force ordering with the
> * next idle sojourn.
> */
> rcu_task_trace_heavyweight_enter(); // Before CT state update!
> - seq = ct_state_inc(offset);
> - // RCU is no longer watching. Better be in extended quiescent state!
> - WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && (seq & CT_RCU_WATCHING));
> + // RCU is still watching. Better not be in extended quiescent state!
> + WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && !rcu_is_watching_curr_cpu());
> + (void)ct_state_inc(offset);
> + // RCU is no longer watching.
> }
>
> /*
>
prev parent reply other threads:[~2025-02-06 17:38 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-16 20:05 [PATCH rcu 0/5] Miscellaneous fixes Paul E. McKenney
2025-01-16 20:05 ` [PATCH rcu 1/5] rcu: Split rcu_report_exp_cpu_mult() mask parameter and use for tracing Paul E. McKenney
2025-01-16 20:05 ` [PATCH rcu 2/5] rcu: Remove READ_ONCE() for rdp->gpwrap access in __note_gp_changes() Paul E. McKenney
2025-01-16 20:05 ` [PATCH rcu 3/5] rcu: Fix get_state_synchronize_rcu_full() GP-start detection Paul E. McKenney
2025-01-16 20:05 ` [PATCH rcu 4/5] rcu-tasks: Move RCU Tasks self-tests to core_initcall() Paul E. McKenney
2025-01-16 20:05 ` [PATCH rcu 5/5] rcu/nocb: Print segment lengths in show_rcu_nocb_gp_state() Paul E. McKenney
2025-01-30 18:53 ` [PATCH rcu 0/5] Miscellaneous fixes Paul E. McKenney
2025-01-30 18:53 ` [PATCH rcu v2] 1/5] rcu: Split rcu_report_exp_cpu_mult() mask parameter and use for tracing Paul E. McKenney
2025-01-30 18:53 ` [PATCH rcu v2] 2/5] rcu: Remove READ_ONCE() for rdp->gpwrap access in __note_gp_changes() Paul E. McKenney
2025-01-30 18:53 ` [PATCH rcu v2] 3/5] rcu: Fix get_state_synchronize_rcu_full() GP-start detection Paul E. McKenney
2025-01-30 18:53 ` [PATCH rcu v2] 4/5] rcu-tasks: Move RCU Tasks self-tests to core_initcall() Paul E. McKenney
2025-02-04 10:26 ` Sebastian Andrzej Siewior
2025-02-04 11:51 ` Paul E. McKenney
2025-02-04 16:34 ` Sebastian Andrzej Siewior
2025-02-04 20:20 ` Paul E. McKenney
2025-02-05 14:50 ` Paul E. McKenney
2025-02-05 19:54 ` John Ogness
2025-02-05 20:10 ` Paul E. McKenney
2025-02-05 20:31 ` Paul E. McKenney
2025-02-05 21:22 ` John Ogness
2025-02-05 21:55 ` Paul E. McKenney
2025-02-05 22:20 ` John Ogness
2025-02-05 22:31 ` John Ogness
2025-02-05 23:50 ` Paul E. McKenney
2025-02-06 8:28 ` John Ogness
2025-02-06 9:58 ` Paul E. McKenney
2025-02-06 9:02 ` Sebastian Andrzej Siewior
2025-02-06 9:59 ` Paul E. McKenney
2025-02-06 10:18 ` Paul E. McKenney
2025-02-06 11:06 ` Petr Mladek
2025-02-06 16:32 ` Paul E. McKenney
2025-01-30 18:53 ` [PATCH rcu v2] 5/5] rcu/nocb: Print segment lengths in show_rcu_nocb_gp_state() Paul E. McKenney
2025-02-06 10:15 ` [PATCH rcu 6/5] Make RCU watch ct_kernel_exit_state() warning Paul E. McKenney
2025-02-06 17:38 ` Boqun Feng [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=Z6TzfG4UZyKcpRzB@Mac.home \
--to=boqun.feng@gmail.com \
--cc=frederic@kernel.org \
--cc=kernel-team@meta.com \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=vschneid@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox