mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@kernel.org>
To: rcu@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com,
	rostedt@goodmis.org, "Paul E. McKenney" <paulmck@kernel.org>,
	Jiri Olsa <jolsa@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>, Yonghong Song <yhs@fb.com>
Subject: [PATCH rcu 02/23] rcu: Apply noinstr to rcu_idle_enter() and rcu_idle_exit()
Date: Mon, 20 Jun 2022 16:10:08 -0700	[thread overview]
Message-ID: <20220620231029.3844583-2-paulmck@kernel.org> (raw)
In-Reply-To: <20220620231027.GA3844372@paulmck-ThinkPad-P17-Gen-1>

This commit applies the "noinstr" tag to the rcu_idle_enter() and
rcu_idle_exit() functions, which are invoked from portions of the idle
loop that cannot be instrumented.  These tags require reworking the
rcu_eqs_enter() and rcu_eqs_exit() functions that these two functions
invoke in order to cause them to use normal assertions rather than
lockdep.  In addition, within rcu_idle_exit(), the raw versions of
local_irq_save() and local_irq_restore() are used, again to avoid issues
with lockdep in uninstrumented code.

This patch is based in part on an earlier patch by Jiri Olsa, discussions
with Peter Zijlstra and Frederic Weisbecker, earlier changes by Thomas
Gleixner, and off-list discussions with Yonghong Song.

Link: https://lore.kernel.org/lkml/20220515203653.4039075-1-jolsa@kernel.org/
Reported-by: Jiri Olsa <jolsa@kernel.org>
Reported-by: Alexei Starovoitov <ast@kernel.org>
Reported-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Yonghong Song <yhs@fb.com>
---
 kernel/rcu/tree.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index c25ba442044a6..9a5edab5558c9 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -631,8 +631,8 @@ static noinstr void rcu_eqs_enter(bool user)
 		return;
 	}
 
-	lockdep_assert_irqs_disabled();
 	instrumentation_begin();
+	lockdep_assert_irqs_disabled();
 	trace_rcu_dyntick(TPS("Start"), rdp->dynticks_nesting, 0, atomic_read(&rdp->dynticks));
 	WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && !user && !is_idle_task(current));
 	rcu_preempt_deferred_qs(current);
@@ -659,9 +659,9 @@ static noinstr void rcu_eqs_enter(bool user)
  * If you add or remove a call to rcu_idle_enter(), be sure to test with
  * CONFIG_RCU_EQS_DEBUG=y.
  */
-void rcu_idle_enter(void)
+void noinstr rcu_idle_enter(void)
 {
-	lockdep_assert_irqs_disabled();
+	WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && !raw_irqs_disabled());
 	rcu_eqs_enter(false);
 }
 EXPORT_SYMBOL_GPL(rcu_idle_enter);
@@ -861,7 +861,7 @@ static void noinstr rcu_eqs_exit(bool user)
 	struct rcu_data *rdp;
 	long oldval;
 
-	lockdep_assert_irqs_disabled();
+	WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && !raw_irqs_disabled());
 	rdp = this_cpu_ptr(&rcu_data);
 	oldval = rdp->dynticks_nesting;
 	WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && oldval < 0);
@@ -896,13 +896,13 @@ static void noinstr rcu_eqs_exit(bool user)
  * If you add or remove a call to rcu_idle_exit(), be sure to test with
  * CONFIG_RCU_EQS_DEBUG=y.
  */
-void rcu_idle_exit(void)
+void noinstr rcu_idle_exit(void)
 {
 	unsigned long flags;
 
-	local_irq_save(flags);
+	raw_local_irq_save(flags);
 	rcu_eqs_exit(false);
-	local_irq_restore(flags);
+	raw_local_irq_restore(flags);
 }
 EXPORT_SYMBOL_GPL(rcu_idle_exit);
 
-- 
2.31.1.189.g2e36527f23


  parent reply	other threads:[~2022-06-20 23:12 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20 23:10 [PATCH rcu 0/23] RCU/context-tracking updates for v5.20 Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 01/23] rcu: Dump rcuc kthread status for CPUs not reporting quiescent state Paul E. McKenney
2022-06-20 23:10 ` Paul E. McKenney [this message]
2022-06-20 23:10 ` [PATCH rcu 03/23] context_tracking: Remove unused context_tracking_in_user() Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 04/23] context_tracking: Add a note about noinstr VS unsafe context tracking functions Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 05/23] context_tracking: Rename __context_tracking_enter/exit() to __ct_user_enter/exit() Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 06/23] context_tracking: Rename context_tracking_user_enter/exit() to user_enter/exit_callable() Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 07/23] context_tracking: Rename context_tracking_enter/exit() to ct_user_enter/exit() Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 08/23] context_tracking: Rename context_tracking_cpu_set() to ct_cpu_track_user() Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 09/23] context_tracking: Split user tracking Kconfig Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 10/23] context_tracking: Take idle eqs entrypoints over RCU Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 11/23] context_tracking: Take IRQ " Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 12/23] context_tracking: Take NMI " Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 13/23] rcu/context-tracking: Remove rcu_irq_enter/exit() Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 14/23] rcu/context_tracking: Move dynticks counter to context tracking Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 15/23] rcu/context_tracking: Move dynticks_nesting " Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 16/23] rcu/context_tracking: Move dynticks_nmi_nesting " Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 17/23] rcu/context-tracking: Move deferred nocb resched " Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 18/23] rcu/context-tracking: Move RCU-dynticks internal functions to context_tracking Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 19/23] rcu/context-tracking: Remove unused and/or unecessary middle functions Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 20/23] context_tracking: Convert state to atomic_t Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 21/23] rcu/context_tracking: Merge dynticks counter and context tracking states Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 22/23] MAINTAINERS: Add Paul as context tracking maintainer Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 23/23] context_tracking: Interrupts always disabled for ct_idle_exit() Paul E. McKenney

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=20220620231029.3844583-2-paulmck@kernel.org \
    --to=paulmck@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=jolsa@kernel.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=yhs@fb.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

all inboxes | Powered by JetHome®