linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com,
	akpm@linux-foundation.org, mathieu.desnoyers@efficios.com,
	josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org,
	rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com,
	fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: [PATCH tip/core/rcu 23/24] rcu: Define rcu_all_qs() only in !PREEMPT builds
Date: Wed, 29 Aug 2018 15:54:04 -0700	[thread overview]
Message-ID: <20180829225405.7275-23-paulmck@linux.vnet.ibm.com> (raw)
In-Reply-To: <20180829225340.GA7019@linux.vnet.ibm.com>

Now that rcu_all_qs() is used only in !PREEMPT builds, move it to
tree_plugin.h so that it is defined only in those builds.  This in
turn means that rcu_momentary_dyntick_idle() is only used in !PREEMPT
builds, but it is simply marked __maybe_unused in order to keep it
near the rest of the dyntick-idle code.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 include/linux/rcutree.h  |  2 ++
 kernel/rcu/tree.c        | 41 +---------------------------------------
 kernel/rcu/tree_plugin.h | 39 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/include/linux/rcutree.h b/include/linux/rcutree.h
index d09a9abe9440..7f83179177d1 100644
--- a/include/linux/rcutree.h
+++ b/include/linux/rcutree.h
@@ -66,7 +66,9 @@ void rcu_scheduler_starting(void);
 extern int rcu_scheduler_active __read_mostly;
 void rcu_end_inkernel_boot(void);
 bool rcu_is_watching(void);
+#ifndef CONFIG_PREEMPT
 void rcu_all_qs(void);
+#endif
 
 /* RCUtree hotplug events */
 int rcutree_prepare_cpu(unsigned int cpu);
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index e8fbb7ee76cc..5f2a12a65b42 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -356,7 +356,7 @@ bool rcu_eqs_special_set(int cpu)
  *
  * The caller must have disabled interrupts and must not be idle.
  */
-static void rcu_momentary_dyntick_idle(void)
+static void __maybe_unused rcu_momentary_dyntick_idle(void)
 {
 	struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks);
 	int special;
@@ -381,45 +381,6 @@ static int rcu_is_cpu_rrupt_from_idle(void)
 	       __this_cpu_read(rcu_dynticks.dynticks_nmi_nesting) <= 1;
 }
 
-/*
- * Register an urgently needed quiescent state.  If there is an
- * emergency, invoke rcu_momentary_dyntick_idle() to do a heavy-weight
- * dyntick-idle quiescent state visible to other CPUs, which will in
- * some cases serve for expedited as well as normal grace periods.
- * Either way, register a lightweight quiescent state.
- *
- * The barrier() calls are redundant in the common case when this is
- * called externally, but just in case this is called from within this
- * file.
- *
- */
-void rcu_all_qs(void)
-{
-	unsigned long flags;
-
-	if (!raw_cpu_read(rcu_dynticks.rcu_urgent_qs))
-		return;
-	preempt_disable();
-	/* Load rcu_urgent_qs before other flags. */
-	if (!smp_load_acquire(this_cpu_ptr(&rcu_dynticks.rcu_urgent_qs))) {
-		preempt_enable();
-		return;
-	}
-	this_cpu_write(rcu_dynticks.rcu_urgent_qs, false);
-	barrier(); /* Avoid RCU read-side critical sections leaking down. */
-	if (unlikely(raw_cpu_read(rcu_dynticks.rcu_need_heavy_qs))) {
-		local_irq_save(flags);
-		rcu_momentary_dyntick_idle();
-		local_irq_restore(flags);
-	}
-	if (unlikely(raw_cpu_read(rcu_data.cpu_no_qs.b.exp)))
-		rcu_qs();
-	this_cpu_inc(rcu_dynticks.rcu_qs_ctr);
-	barrier(); /* Avoid RCU read-side critical sections leaking up. */
-	preempt_enable();
-}
-EXPORT_SYMBOL_GPL(rcu_all_qs);
-
 #define DEFAULT_RCU_BLIMIT 10     /* Maximum callbacks per rcu_do_batch. */
 static long blimit = DEFAULT_RCU_BLIMIT;
 #define DEFAULT_RCU_QHIMARK 10000 /* If this many pending, ignore blimit. */
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index cd4c1b979446..7add1c297500 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -947,6 +947,45 @@ static void rcu_qs(void)
 	rcu_report_exp_rdp(this_cpu_ptr(&rcu_data));
 }
 
+/*
+ * Register an urgently needed quiescent state.  If there is an
+ * emergency, invoke rcu_momentary_dyntick_idle() to do a heavy-weight
+ * dyntick-idle quiescent state visible to other CPUs, which will in
+ * some cases serve for expedited as well as normal grace periods.
+ * Either way, register a lightweight quiescent state.
+ *
+ * The barrier() calls are redundant in the common case when this is
+ * called externally, but just in case this is called from within this
+ * file.
+ *
+ */
+void rcu_all_qs(void)
+{
+	unsigned long flags;
+
+	if (!raw_cpu_read(rcu_dynticks.rcu_urgent_qs))
+		return;
+	preempt_disable();
+	/* Load rcu_urgent_qs before other flags. */
+	if (!smp_load_acquire(this_cpu_ptr(&rcu_dynticks.rcu_urgent_qs))) {
+		preempt_enable();
+		return;
+	}
+	this_cpu_write(rcu_dynticks.rcu_urgent_qs, false);
+	barrier(); /* Avoid RCU read-side critical sections leaking down. */
+	if (unlikely(raw_cpu_read(rcu_dynticks.rcu_need_heavy_qs))) {
+		local_irq_save(flags);
+		rcu_momentary_dyntick_idle();
+		local_irq_restore(flags);
+	}
+	if (unlikely(raw_cpu_read(rcu_data.cpu_no_qs.b.exp)))
+		rcu_qs();
+	this_cpu_inc(rcu_dynticks.rcu_qs_ctr);
+	barrier(); /* Avoid RCU read-side critical sections leaking up. */
+	preempt_enable();
+}
+EXPORT_SYMBOL_GPL(rcu_all_qs);
+
 /*
  * Note a PREEMPT=n context switch.  The caller must have disabled interrupts.
  */
-- 
2.17.1


  parent reply	other threads:[~2018-08-29 22:54 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-29 22:53 [PATCH tip/core/rcu 0/24] Additional RCU-consolidation cleanups for v4.20/v5.0 Paul E. McKenney
2018-08-29 22:53 ` [PATCH tip/core/rcu 01/24] rcu: Inline increment_cpu_stall_ticks() into its sole caller Paul E. McKenney
2018-08-29 22:53 ` [PATCH tip/core/rcu 02/24] rcu: Pull rcu_gp_kthread() FQS loop into separate function Paul E. McKenney
2018-08-29 22:53 ` [PATCH tip/core/rcu 03/24] rcu: Consolidate RCU-bh update-side function definitions Paul E. McKenney
2018-08-29 22:53 ` [PATCH tip/core/rcu 04/24] rcu: Consolidate RCU-sched " Paul E. McKenney
2018-08-29 22:53 ` [PATCH tip/core/rcu 05/24] rcutorture: Add RCU-bh and RCU-sched support for extended readers Paul E. McKenney
2018-08-29 22:53 ` [PATCH tip/core/rcu 06/24] rcu: Stop testing RCU-bh and RCU-sched Paul E. McKenney
2018-08-29 22:53 ` [PATCH tip/core/rcu 07/24] rcutorture: Remove the "rcu_bh" and "sched" torture types Paul E. McKenney
2018-08-29 22:53 ` [PATCH tip/core/rcu 08/24] rcuperf: " Paul E. McKenney
2018-08-29 22:53 ` [PATCH tip/core/rcu 09/24] rcu: Remove now-unused rcutorture APIs Paul E. McKenney
2018-08-29 22:53 ` [PATCH tip/core/rcu 10/24] rcu: Clean up flavor-related definitions and comments in rcupdate.h Paul E. McKenney
2018-08-29 22:53 ` [PATCH tip/core/rcu 11/24] rcu: Clean up flavor-related definitions and comments in rculist.h Paul E. McKenney
2018-08-29 22:53 ` [PATCH tip/core/rcu 12/24] rcu: Clean up flavor-related definitions and comments in rcupdate_wait.h Paul E. McKenney
2018-08-29 22:53 ` [PATCH tip/core/rcu 13/24] rcu: Clean up flavor-related definitions and comments in Kconfig Paul E. McKenney
2018-08-29 22:53 ` [PATCH tip/core/rcu 14/24] rcu: Clean up flavor-related definitions and comments in rcu.h Paul E. McKenney
2018-08-29 22:53 ` [PATCH tip/core/rcu 15/24] rcu: Clean up flavor-related definitions and comments in rcutorture.c Paul E. McKenney
2018-08-29 22:53 ` [PATCH tip/core/rcu 16/24] rcu: Clean up flavor-related definitions and comments in srcutree.h Paul E. McKenney
2018-08-29 22:53 ` [PATCH tip/core/rcu 17/24] rcu: Clean up flavor-related definitions and comments in tiny.c Paul E. McKenney
2018-08-29 22:53 ` [PATCH tip/core/rcu 18/24] rcu: Clean up flavor-related definitions and comments in tree.c Paul E. McKenney
2018-08-29 22:54 ` [PATCH tip/core/rcu 19/24] rcu: Clean up flavor-related definitions and comments in tree_exp.h Paul E. McKenney
2018-08-29 22:54 ` [PATCH tip/core/rcu 20/24] rcu: Clean up flavor-related definitions and comments in tree_plugin.h Paul E. McKenney
2018-08-29 22:54 ` [PATCH tip/core/rcu 21/24] rcu: Clean up flavor-related definitions and comments in update.c Paul E. McKenney
2018-08-29 22:54 ` [PATCH tip/core/rcu 22/24] rcu: Remove !PREEMPT code from rcu_note_voluntary_context_switch() Paul E. McKenney
2018-08-29 22:54 ` Paul E. McKenney [this message]
2018-08-29 22:54 ` [PATCH tip/core/rcu 24/24] rcu: Inline _rcu_barrier() into its sole remaining caller 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=20180829225405.7275-23-paulmck@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=edumazet@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).