linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5
@ 2015-12-04 23:58 Paul E. McKenney
  2015-12-05  0:10 ` [PATCH tip/core/rcu 01/13] rcu: Move lock_class_key to local scope Paul E. McKenney
                   ` (13 more replies)
  0 siblings, 14 replies; 16+ messages in thread
From: Paul E. McKenney @ 2015-12-04 23:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh,
	tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec,
	oleg, bobby.prani

Hello!

This series contains follow-on cleanup changes to RCU's expedited
grace-period functionality.  The patches in this series are as follows:

1.	Short-circuit synchronize_sched_expedited() if there is only one CPU.

2.	Update comment to clarify the role of ->expmaskinitnext.

3.	Separate concerns by moving smp_mb() from rcu_seq_snap() to
	rcu_exp_gp_seq_snap().

4.	Safe a few lines of code by inverting the sense of
	sync_rcu_exp_select_cpus() "if" statement.

5.	Reduce expedited GP memory contention via per-CPU variables.

6.	Get rid of (some) empty stall-warning messages by resolving
	stall-warning ties.

7.	Add more diagnostics to expedited stall warning messages.

8.	Add rcu_normal kernel parameter to suppress expediting for
	the benefit of aggressive real-time systems.

9-10.	Allow expedited grace periods to be disabled just before init
	is spawned, allowing them to speed up boot without interfering
	with run-time real-time workloads.

							Thanx, Paul

------------------------------------------------------------------------

 b/Documentation/kernel-parameters.txt |   24 ++++++++--
 b/include/linux/rcupdate.h            |    6 ++
 b/init/main.c                         |    2 
 b/kernel/ksysfs.c                     |   22 ++++++++-
 b/kernel/rcu/srcu.c                   |    2 
 b/kernel/rcu/tree.c                   |   79 ++++++++++++++++++++++------------
 b/kernel/rcu/tree.h                   |   10 ++--
 b/kernel/rcu/tree_plugin.h            |    6 ++
 b/kernel/rcu/tree_trace.c             |   18 +++++--
 b/kernel/rcu/update.c                 |   17 +++++++
 10 files changed, 141 insertions(+), 45 deletions(-)


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH tip/core/rcu 01/13] rcu: Move lock_class_key to local scope
  2015-12-04 23:58 [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5 Paul E. McKenney
@ 2015-12-05  0:10 ` Paul E. McKenney
  2015-12-05  0:10 ` [PATCH tip/core/rcu 02/13] kernel: Make rcu/tree_trace.c explicitly non-modular Paul E. McKenney
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Paul E. McKenney @ 2015-12-05  0:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh,
	tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec,
	oleg, bobby.prani, Paul E. McKenney

Currently, the rcu_node_class[], rcu_fqs_class[], and rcu_exp_class[]
arrays needlessly pollute the global namespace within tree.c.  This
commit therefore converts them to static local variables within
rcu_init_one().

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 kernel/rcu/tree.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 81aa1cdc6bc9..23df2661c899 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -68,10 +68,6 @@ MODULE_ALIAS("rcutree");
 
 /* Data structures. */
 
-static struct lock_class_key rcu_node_class[RCU_NUM_LVLS];
-static struct lock_class_key rcu_fqs_class[RCU_NUM_LVLS];
-static struct lock_class_key rcu_exp_class[RCU_NUM_LVLS];
-
 /*
  * In order to export the rcu_state name to the tracing tools, it
  * needs to be added in the __tracepoint_string section.
@@ -4365,6 +4361,9 @@ static void __init rcu_init_one(struct rcu_state *rsp,
 	static const char * const buf[] = RCU_NODE_NAME_INIT;
 	static const char * const fqs[] = RCU_FQS_NAME_INIT;
 	static const char * const exp[] = RCU_EXP_NAME_INIT;
+	static struct lock_class_key rcu_node_class[RCU_NUM_LVLS];
+	static struct lock_class_key rcu_fqs_class[RCU_NUM_LVLS];
+	static struct lock_class_key rcu_exp_class[RCU_NUM_LVLS];
 	static u8 fl_mask = 0x1;
 
 	int levelcnt[RCU_NUM_LVLS];		/* # nodes in each level. */
-- 
2.5.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH tip/core/rcu 02/13] kernel: Make rcu/tree_trace.c explicitly non-modular
  2015-12-04 23:58 [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5 Paul E. McKenney
  2015-12-05  0:10 ` [PATCH tip/core/rcu 01/13] rcu: Move lock_class_key to local scope Paul E. McKenney
@ 2015-12-05  0:10 ` Paul E. McKenney
  2015-12-05  0:10 ` [PATCH tip/core/rcu 03/13] rcu: Simplify rcu_sched_qs() control flow Paul E. McKenney
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Paul E. McKenney @ 2015-12-05  0:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh,
	tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec,
	oleg, bobby.prani, Paul Gortmaker, Paul E. McKenney

From: Paul Gortmaker <paul.gortmaker@windriver.com>

The Kconfig currently controlling compilation of this code is:

init/Kconfig:config TREE_RCU_TRACE
init/Kconfig:   def_bool RCU_TRACE && ( TREE_RCU || PREEMPT_RCU )

...meaning that it currently is not being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that
when reading the file there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular
case, the init ordering remains unchanged with this commit.  We could
consider moving this to an earlier initcall if desired.

We don't replace module.h with init.h since the file already has that.
We also delete the moduleparam.h include that is left over from
commit 64db4cfff99c04cd5f550357edcc8780f96b54a2 (""Tree RCU": scalable
classic RCU implementation") since it is not needed here either.

We morph some tags like MODULE_AUTHOR into the comments at the top of
the file for documentation purposes.

Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Josh Triplett <josh@joshtriplett.org>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 kernel/rcu/tree_trace.c | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/kernel/rcu/tree_trace.c b/kernel/rcu/tree_trace.c
index 8efaba870d96..82aca98b18f8 100644
--- a/kernel/rcu/tree_trace.c
+++ b/kernel/rcu/tree_trace.c
@@ -1,5 +1,5 @@
 /*
- * Read-Copy Update tracing for classic implementation
+ * Read-Copy Update tracing for hierarchical implementation.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -16,6 +16,7 @@
  * http://www.gnu.org/licenses/gpl-2.0.html.
  *
  * Copyright IBM Corporation, 2008
+ * Author: Paul E. McKenney
  *
  * Papers:  http://www.rdrop.com/users/paulmck/RCU
  *
@@ -33,9 +34,7 @@
 #include <linux/sched.h>
 #include <linux/atomic.h>
 #include <linux/bitops.h>
-#include <linux/module.h>
 #include <linux/completion.h>
-#include <linux/moduleparam.h>
 #include <linux/percpu.h>
 #include <linux/notifier.h>
 #include <linux/cpu.h>
@@ -487,16 +486,4 @@ free_out:
 	debugfs_remove_recursive(rcudir);
 	return 1;
 }
-
-static void __exit rcutree_trace_cleanup(void)
-{
-	debugfs_remove_recursive(rcudir);
-}
-
-
-module_init(rcutree_trace_init);
-module_exit(rcutree_trace_cleanup);
-
-MODULE_AUTHOR("Paul E. McKenney");
-MODULE_DESCRIPTION("Read-Copy Update tracing for hierarchical implementation");
-MODULE_LICENSE("GPL");
+device_initcall(rcutree_trace_init);
-- 
2.5.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH tip/core/rcu 03/13] rcu: Simplify rcu_sched_qs() control flow
  2015-12-04 23:58 [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5 Paul E. McKenney
  2015-12-05  0:10 ` [PATCH tip/core/rcu 01/13] rcu: Move lock_class_key to local scope Paul E. McKenney
  2015-12-05  0:10 ` [PATCH tip/core/rcu 02/13] kernel: Make rcu/tree_trace.c explicitly non-modular Paul E. McKenney
@ 2015-12-05  0:10 ` Paul E. McKenney
  2015-12-05  0:10 ` [PATCH tip/core/rcu 04/13] rcu: Remove lock-acquisition loop from rcu_read_unlock_special() Paul E. McKenney
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Paul E. McKenney @ 2015-12-05  0:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh,
	tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec,
	oleg, bobby.prani, Paul E. McKenney

This commit applies an early-exit approach to rcu_sched_qs(), reducing
the nesting level and saving a line of code.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 kernel/rcu/tree.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 23df2661c899..ed3bc0578cc5 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -244,22 +244,21 @@ void rcu_sched_qs(void)
 {
 	unsigned long flags;
 
-	if (__this_cpu_read(rcu_sched_data.cpu_no_qs.s)) {
-		trace_rcu_grace_period(TPS("rcu_sched"),
-				       __this_cpu_read(rcu_sched_data.gpnum),
-				       TPS("cpuqs"));
-		__this_cpu_write(rcu_sched_data.cpu_no_qs.b.norm, false);
-		if (!__this_cpu_read(rcu_sched_data.cpu_no_qs.b.exp))
-			return;
-		local_irq_save(flags);
-		if (__this_cpu_read(rcu_sched_data.cpu_no_qs.b.exp)) {
-			__this_cpu_write(rcu_sched_data.cpu_no_qs.b.exp, false);
-			rcu_report_exp_rdp(&rcu_sched_state,
-					   this_cpu_ptr(&rcu_sched_data),
-					   true);
-		}
-		local_irq_restore(flags);
+	if (!__this_cpu_read(rcu_sched_data.cpu_no_qs.s))
+		return;
+	trace_rcu_grace_period(TPS("rcu_sched"),
+			       __this_cpu_read(rcu_sched_data.gpnum),
+			       TPS("cpuqs"));
+	__this_cpu_write(rcu_sched_data.cpu_no_qs.b.norm, false);
+	if (!__this_cpu_read(rcu_sched_data.cpu_no_qs.b.exp))
+		return;
+	local_irq_save(flags);
+	if (__this_cpu_read(rcu_sched_data.cpu_no_qs.b.exp)) {
+		__this_cpu_write(rcu_sched_data.cpu_no_qs.b.exp, false);
+		rcu_report_exp_rdp(&rcu_sched_state,
+				   this_cpu_ptr(&rcu_sched_data), true);
 	}
+	local_irq_restore(flags);
 }
 
 void rcu_bh_qs(void)
-- 
2.5.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH tip/core/rcu 04/13] rcu: Remove lock-acquisition loop from rcu_read_unlock_special()
  2015-12-04 23:58 [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5 Paul E. McKenney
                   ` (2 preceding siblings ...)
  2015-12-05  0:10 ` [PATCH tip/core/rcu 03/13] rcu: Simplify rcu_sched_qs() control flow Paul E. McKenney
@ 2015-12-05  0:10 ` Paul E. McKenney
  2015-12-05  0:10 ` [PATCH tip/core/rcu 05/13] rcu: Fix obsolete rcu_bootup_announce_oddness() comment Paul E. McKenney
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Paul E. McKenney @ 2015-12-05  0:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh,
	tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec,
	oleg, bobby.prani, Paul E. McKenney

Several releases have come and gone without the warning triggering,
so remove the lock-acquisition loop.  Retain the WARN_ON_ONCE()
out of sheer paranoia.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 kernel/rcu/tree_plugin.h | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 57ba873d2f18..ae4ce2b665f8 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -449,19 +449,13 @@ void rcu_read_unlock_special(struct task_struct *t)
 
 		/*
 		 * Remove this task from the list it blocked on.  The task
-		 * now remains queued on the rcu_node corresponding to
-		 * the CPU it first blocked on, so the first attempt to
-		 * acquire the task's rcu_node's ->lock will succeed.
-		 * Keep the loop and add a WARN_ON() out of sheer paranoia.
+		 * now remains queued on the rcu_node corresponding to the
+		 * CPU it first blocked on, so there is no longer any need
+		 * to loop.  Retain a WARN_ON_ONCE() out of sheer paranoia.
 		 */
-		for (;;) {
-			rnp = t->rcu_blocked_node;
-			raw_spin_lock_rcu_node(rnp); /* irqs already disabled. */
-			if (rnp == t->rcu_blocked_node)
-				break;
-			WARN_ON_ONCE(1);
-			raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
-		}
+		rnp = t->rcu_blocked_node;
+		raw_spin_lock_rcu_node(rnp); /* irqs already disabled. */
+		WARN_ON_ONCE(rnp != t->rcu_blocked_node);
 		empty_norm = !rcu_preempt_blocked_readers_cgp(rnp);
 		empty_exp = sync_rcu_preempt_exp_done(rnp);
 		smp_mb(); /* ensure expedited fastpath sees end of RCU c-s. */
-- 
2.5.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH tip/core/rcu 05/13] rcu: Fix obsolete rcu_bootup_announce_oddness() comment
  2015-12-04 23:58 [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5 Paul E. McKenney
                   ` (3 preceding siblings ...)
  2015-12-05  0:10 ` [PATCH tip/core/rcu 04/13] rcu: Remove lock-acquisition loop from rcu_read_unlock_special() Paul E. McKenney
@ 2015-12-05  0:10 ` Paul E. McKenney
  2015-12-05  0:10 ` [PATCH tip/core/rcu 06/13] rcu: Avoid tick_nohz_active checks on NOCBs CPUs Paul E. McKenney
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Paul E. McKenney @ 2015-12-05  0:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh,
	tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec,
	oleg, bobby.prani, Paul E. McKenney

This function no longer has #ifdefs, so this commit removes the
header comment calling them out.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 kernel/rcu/tree_plugin.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index ae4ce2b665f8..42df93721e6f 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -63,8 +63,7 @@ static bool __read_mostly rcu_nocb_poll;    /* Offload kthread are to poll. */
 
 /*
  * Check the RCU kernel configuration parameters and print informative
- * messages about anything out of the ordinary.  If you like #ifdef, you
- * will love this function.
+ * messages about anything out of the ordinary.
  */
 static void __init rcu_bootup_announce_oddness(void)
 {
-- 
2.5.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH tip/core/rcu 06/13] rcu: Avoid tick_nohz_active checks on NOCBs CPUs
  2015-12-04 23:58 [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5 Paul E. McKenney
                   ` (4 preceding siblings ...)
  2015-12-05  0:10 ` [PATCH tip/core/rcu 05/13] rcu: Fix obsolete rcu_bootup_announce_oddness() comment Paul E. McKenney
@ 2015-12-05  0:10 ` Paul E. McKenney
  2015-12-05  0:10 ` [PATCH tip/core/rcu 07/13] rcu: Stop disabling interrupts in scheduler fastpaths Paul E. McKenney
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Paul E. McKenney @ 2015-12-05  0:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh,
	tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec,
	oleg, bobby.prani, Paul E. McKenney

Currently, rcu_prepare_for_idle() checks for tick_nohz_active, even on
individual NOCBs CPUs, unless all CPUs are marked as NOCBs CPUs at build
time.  This check is pointless on NOCBs CPUs because they never have any
callbacks posted, given that all of their callbacks are handed off to the
corresponding rcuo kthread.  There is a check for individually designated
NOCBs CPUs, but it pointelessly follows the check for tick_nohz_active.

This commit therefore moves the check for individually designated NOCBs
CPUs up with the check for CONFIG_RCU_NOCB_CPU_ALL.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 kernel/rcu/tree_plugin.h | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 42df93721e6f..8e9d4a4d0326 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -1513,7 +1513,8 @@ static void rcu_prepare_for_idle(void)
 	struct rcu_state *rsp;
 	int tne;
 
-	if (IS_ENABLED(CONFIG_RCU_NOCB_CPU_ALL))
+	if (IS_ENABLED(CONFIG_RCU_NOCB_CPU_ALL) ||
+	    rcu_is_nocb_cpu(smp_processor_id()))
 		return;
 
 	/* Handle nohz enablement switches conservatively. */
@@ -1527,10 +1528,6 @@ static void rcu_prepare_for_idle(void)
 	if (!tne)
 		return;
 
-	/* If this is a no-CBs CPU, no callbacks, just return. */
-	if (rcu_is_nocb_cpu(smp_processor_id()))
-		return;
-
 	/*
 	 * If a non-lazy callback arrived at a CPU having only lazy
 	 * callbacks, invoke RCU core for the side-effect of recalculating
-- 
2.5.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH tip/core/rcu 07/13] rcu: Stop disabling interrupts in scheduler fastpaths
  2015-12-04 23:58 [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5 Paul E. McKenney
                   ` (5 preceding siblings ...)
  2015-12-05  0:10 ` [PATCH tip/core/rcu 06/13] rcu: Avoid tick_nohz_active checks on NOCBs CPUs Paul E. McKenney
@ 2015-12-05  0:10 ` Paul E. McKenney
  2015-12-05  0:10 ` [PATCH tip/core/rcu 08/13] rcu: Eliminate unused rcu_init_one() argument Paul E. McKenney
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Paul E. McKenney @ 2015-12-05  0:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh,
	tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec,
	oleg, bobby.prani, Paul E. McKenney

We need the scheduler's fastpaths to be, well, fast, and unnecessarily
disabling and re-enabling interrupts is not necessarily consistent with
this goal.  Especially given that there are regions of the scheduler that
already have interrupts disabled.

This commit therefore moves the call to rcu_note_context_switch()
to one of the interrupts-disabled regions of the scheduler, and
removes the now-redundant disabling and re-enabling of interrupts from
rcu_note_context_switch() and the functions it calls.

Reported-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
[ paulmck: Shift rcu_note_context_switch() to avoid deadlock, as suggested
  by Peter Zijlstra. ]
---
 include/linux/rcutree.h  |  2 +-
 kernel/rcu/tree.c        | 27 ++++++++++++---------------
 kernel/rcu/tree_plugin.h | 14 ++++++--------
 kernel/sched/core.c      |  6 ++++--
 4 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/include/linux/rcutree.h b/include/linux/rcutree.h
index 60d15a080d7c..9d3eda39bcd2 100644
--- a/include/linux/rcutree.h
+++ b/include/linux/rcutree.h
@@ -37,7 +37,7 @@ void rcu_cpu_stall_reset(void);
 /*
  * Note a virtualization-based context switch.  This is simply a
  * wrapper around rcu_note_context_switch(), which allows TINY_RCU
- * to save a few bytes.
+ * to save a few bytes. The caller must have disabled interrupts.
  */
 static inline void rcu_virt_note_context_switch(int cpu)
 {
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index ed3bc0578cc5..93941d3434ad 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -242,8 +242,6 @@ static int rcu_gp_in_progress(struct rcu_state *rsp)
  */
 void rcu_sched_qs(void)
 {
-	unsigned long flags;
-
 	if (!__this_cpu_read(rcu_sched_data.cpu_no_qs.s))
 		return;
 	trace_rcu_grace_period(TPS("rcu_sched"),
@@ -252,13 +250,9 @@ void rcu_sched_qs(void)
 	__this_cpu_write(rcu_sched_data.cpu_no_qs.b.norm, false);
 	if (!__this_cpu_read(rcu_sched_data.cpu_no_qs.b.exp))
 		return;
-	local_irq_save(flags);
-	if (__this_cpu_read(rcu_sched_data.cpu_no_qs.b.exp)) {
-		__this_cpu_write(rcu_sched_data.cpu_no_qs.b.exp, false);
-		rcu_report_exp_rdp(&rcu_sched_state,
-				   this_cpu_ptr(&rcu_sched_data), true);
-	}
-	local_irq_restore(flags);
+	__this_cpu_write(rcu_sched_data.cpu_no_qs.b.exp, false);
+	rcu_report_exp_rdp(&rcu_sched_state,
+			   this_cpu_ptr(&rcu_sched_data), true);
 }
 
 void rcu_bh_qs(void)
@@ -295,17 +289,16 @@ EXPORT_PER_CPU_SYMBOL_GPL(rcu_qs_ctr);
  * We inform the RCU core by emulating a zero-duration dyntick-idle
  * period, which we in turn do by incrementing the ->dynticks counter
  * by two.
+ *
+ * The caller must have disabled interrupts.
  */
 static void rcu_momentary_dyntick_idle(void)
 {
-	unsigned long flags;
 	struct rcu_data *rdp;
 	struct rcu_dynticks *rdtp;
 	int resched_mask;
 	struct rcu_state *rsp;
 
-	local_irq_save(flags);
-
 	/*
 	 * Yes, we can lose flag-setting operations.  This is OK, because
 	 * the flag will be set again after some delay.
@@ -335,13 +328,12 @@ static void rcu_momentary_dyntick_idle(void)
 		smp_mb__after_atomic(); /* Later stuff after QS. */
 		break;
 	}
-	local_irq_restore(flags);
 }
 
 /*
  * Note a context switch.  This is a quiescent state for RCU-sched,
  * and requires special handling for preemptible RCU.
- * The caller must have disabled preemption.
+ * The caller must have disabled interrupts.
  */
 void rcu_note_context_switch(void)
 {
@@ -371,9 +363,14 @@ EXPORT_SYMBOL_GPL(rcu_note_context_switch);
  */
 void rcu_all_qs(void)
 {
+	unsigned long flags;
+
 	barrier(); /* Avoid RCU read-side critical sections leaking down. */
-	if (unlikely(raw_cpu_read(rcu_sched_qs_mask)))
+	if (unlikely(raw_cpu_read(rcu_sched_qs_mask))) {
+		local_irq_save(flags);
 		rcu_momentary_dyntick_idle();
+		local_irq_restore(flags);
+	}
 	this_cpu_inc(rcu_qs_ctr);
 	barrier(); /* Avoid RCU read-side critical sections leaking up. */
 }
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 8e9d4a4d0326..e6da888cc908 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -146,8 +146,8 @@ static void __init rcu_bootup_announce(void)
  * the corresponding expedited grace period will also be the end of the
  * normal grace period.
  */
-static void rcu_preempt_ctxt_queue(struct rcu_node *rnp, struct rcu_data *rdp,
-				   unsigned long flags) __releases(rnp->lock)
+static void rcu_preempt_ctxt_queue(struct rcu_node *rnp, struct rcu_data *rdp)
+	__releases(rnp->lock) /* But leaves rrupts disabled. */
 {
 	int blkd_state = (rnp->gp_tasks ? RCU_GP_TASKS : 0) +
 			 (rnp->exp_tasks ? RCU_EXP_TASKS : 0) +
@@ -235,7 +235,7 @@ static void rcu_preempt_ctxt_queue(struct rcu_node *rnp, struct rcu_data *rdp,
 		rnp->gp_tasks = &t->rcu_node_entry;
 	if (!rnp->exp_tasks && (blkd_state & RCU_EXP_BLKD))
 		rnp->exp_tasks = &t->rcu_node_entry;
-	raw_spin_unlock(&rnp->lock);
+	raw_spin_unlock(&rnp->lock); /* rrupts remain disabled. */
 
 	/*
 	 * Report the quiescent state for the expedited GP.  This expedited
@@ -250,7 +250,6 @@ static void rcu_preempt_ctxt_queue(struct rcu_node *rnp, struct rcu_data *rdp,
 	} else {
 		WARN_ON_ONCE(t->rcu_read_unlock_special.b.exp_need_qs);
 	}
-	local_irq_restore(flags);
 }
 
 /*
@@ -285,12 +284,11 @@ static void rcu_preempt_qs(void)
  * predating the current grace period drain, in other words, until
  * rnp->gp_tasks becomes NULL.
  *
- * Caller must disable preemption.
+ * Caller must disable interrupts.
  */
 static void rcu_preempt_note_context_switch(void)
 {
 	struct task_struct *t = current;
-	unsigned long flags;
 	struct rcu_data *rdp;
 	struct rcu_node *rnp;
 
@@ -300,7 +298,7 @@ static void rcu_preempt_note_context_switch(void)
 		/* Possibly blocking in an RCU read-side critical section. */
 		rdp = this_cpu_ptr(rcu_state_p->rda);
 		rnp = rdp->mynode;
-		raw_spin_lock_irqsave_rcu_node(rnp, flags);
+		raw_spin_lock_rcu_node(rnp);
 		t->rcu_read_unlock_special.b.blocked = true;
 		t->rcu_blocked_node = rnp;
 
@@ -316,7 +314,7 @@ static void rcu_preempt_note_context_switch(void)
 				       (rnp->qsmask & rdp->grpmask)
 				       ? rnp->gpnum
 				       : rnp->gpnum + 1);
-		rcu_preempt_ctxt_queue(rnp, rdp, flags);
+		rcu_preempt_ctxt_queue(rnp, rdp);
 	} else if (t->rcu_read_lock_nesting < 0 &&
 		   t->rcu_read_unlock_special.s) {
 
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 4d568ac9319e..ec72de234feb 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3085,7 +3085,6 @@ static void __sched notrace __schedule(bool preempt)
 
 	cpu = smp_processor_id();
 	rq = cpu_rq(cpu);
-	rcu_note_context_switch();
 	prev = rq->curr;
 
 	/*
@@ -3104,13 +3103,16 @@ static void __sched notrace __schedule(bool preempt)
 	if (sched_feat(HRTICK))
 		hrtick_clear(rq);
 
+	local_irq_disable();
+	rcu_note_context_switch();
+
 	/*
 	 * Make sure that signal_pending_state()->signal_pending() below
 	 * can't be reordered with __set_current_state(TASK_INTERRUPTIBLE)
 	 * done by the caller to avoid the race with signal_wake_up().
 	 */
 	smp_mb__before_spinlock();
-	raw_spin_lock_irq(&rq->lock);
+	raw_spin_lock(&rq->lock);
 	lockdep_pin_lock(&rq->lock);
 
 	rq->clock_skip_update <<= 1; /* promote REQ to ACT */
-- 
2.5.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH tip/core/rcu 08/13] rcu: Eliminate unused rcu_init_one() argument
  2015-12-04 23:58 [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5 Paul E. McKenney
                   ` (6 preceding siblings ...)
  2015-12-05  0:10 ` [PATCH tip/core/rcu 07/13] rcu: Stop disabling interrupts in scheduler fastpaths Paul E. McKenney
@ 2015-12-05  0:10 ` Paul E. McKenney
  2015-12-05  0:10 ` [PATCH tip/core/rcu 09/13] rcu: Make cpu_needs_another_gp() be bool Paul E. McKenney
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Paul E. McKenney @ 2015-12-05  0:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh,
	tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec,
	oleg, bobby.prani, Paul E. McKenney

Now that the rcu_state structure's ->rda field is compile-time initialized,
there is no need to pass the per-CPU rcu_data structure into rcu_init_one().
This commit therefore eliminates this now-unused paramter.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 kernel/rcu/tree.c        | 7 +++----
 kernel/rcu/tree_plugin.h | 2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 93941d3434ad..9a4c8c0653ff 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -4351,8 +4351,7 @@ static void __init rcu_init_levelspread(int *levelspread, const int *levelcnt)
 /*
  * Helper function for rcu_init() that initializes one rcu_state structure.
  */
-static void __init rcu_init_one(struct rcu_state *rsp,
-		struct rcu_data __percpu *rda)
+static void __init rcu_init_one(struct rcu_state *rsp)
 {
 	static const char * const buf[] = RCU_NODE_NAME_INIT;
 	static const char * const fqs[] = RCU_FQS_NAME_INIT;
@@ -4545,8 +4544,8 @@ void __init rcu_init(void)
 
 	rcu_bootup_announce();
 	rcu_init_geometry();
-	rcu_init_one(&rcu_bh_state, &rcu_bh_data);
-	rcu_init_one(&rcu_sched_state, &rcu_sched_data);
+	rcu_init_one(&rcu_bh_state);
+	rcu_init_one(&rcu_sched_state);
 	if (dump_tree)
 		rcu_dump_rcu_node_tree(&rcu_sched_state);
 	__rcu_init_preempt();
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index e6da888cc908..fccef5d4b198 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -777,7 +777,7 @@ EXPORT_SYMBOL_GPL(rcu_barrier);
  */
 static void __init __rcu_init_preempt(void)
 {
-	rcu_init_one(rcu_state_p, rcu_data_p);
+	rcu_init_one(rcu_state_p);
 }
 
 /*
-- 
2.5.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH tip/core/rcu 09/13] rcu: Make cpu_needs_another_gp() be bool
  2015-12-04 23:58 [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5 Paul E. McKenney
                   ` (7 preceding siblings ...)
  2015-12-05  0:10 ` [PATCH tip/core/rcu 08/13] rcu: Eliminate unused rcu_init_one() argument Paul E. McKenney
@ 2015-12-05  0:10 ` Paul E. McKenney
  2015-12-05  0:10 ` [PATCH tip/core/rcu 10/13] rcu: Don't redundantly disable irqs in rcu_irq_{enter,exit}() Paul E. McKenney
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Paul E. McKenney @ 2015-12-05  0:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh,
	tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec,
	oleg, bobby.prani, Paul E. McKenney

The cpu_needs_another_gp() function is currently of type int, but only
returns zero or one.  Bow to reality and make it be of type bool.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.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 9a4c8c0653ff..d6863bceeb45 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -597,25 +597,25 @@ static int rcu_future_needs_gp(struct rcu_state *rsp)
  * The caller must have disabled interrupts to prevent races with
  * normal callback registry.
  */
-static int
+static bool
 cpu_needs_another_gp(struct rcu_state *rsp, struct rcu_data *rdp)
 {
 	int i;
 
 	if (rcu_gp_in_progress(rsp))
-		return 0;  /* No, a grace period is already in progress. */
+		return false;  /* No, a grace period is already in progress. */
 	if (rcu_future_needs_gp(rsp))
-		return 1;  /* Yes, a no-CBs CPU needs one. */
+		return true;  /* Yes, a no-CBs CPU needs one. */
 	if (!rdp->nxttail[RCU_NEXT_TAIL])
-		return 0;  /* No, this is a no-CBs (or offline) CPU. */
+		return false;  /* No, this is a no-CBs (or offline) CPU. */
 	if (*rdp->nxttail[RCU_NEXT_READY_TAIL])
-		return 1;  /* Yes, this CPU has newly registered callbacks. */
+		return true;  /* Yes, CPU has newly registered callbacks. */
 	for (i = RCU_WAIT_TAIL; i < RCU_NEXT_TAIL; i++)
 		if (rdp->nxttail[i - 1] != rdp->nxttail[i] &&
 		    ULONG_CMP_LT(READ_ONCE(rsp->completed),
 				 rdp->nxtcompleted[i]))
-			return 1;  /* Yes, CBs for future grace period. */
-	return 0; /* No grace period needed. */
+			return true;  /* Yes, CBs for future grace period. */
+	return false; /* No grace period needed. */
 }
 
 /*
-- 
2.5.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH tip/core/rcu 10/13] rcu: Don't redundantly disable irqs in rcu_irq_{enter,exit}()
  2015-12-04 23:58 [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5 Paul E. McKenney
                   ` (8 preceding siblings ...)
  2015-12-05  0:10 ` [PATCH tip/core/rcu 09/13] rcu: Make cpu_needs_another_gp() be bool Paul E. McKenney
@ 2015-12-05  0:10 ` Paul E. McKenney
  2015-12-05  0:10 ` [PATCH tip/core/rcu 11/13] rcu: Fix comment for rcu_dereference_raw_notrace Paul E. McKenney
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Paul E. McKenney @ 2015-12-05  0:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh,
	tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec,
	oleg, bobby.prani, Paul E. McKenney

This commit replaces a local_irq_save()/local_irq_restore() pair with
a lockdep assertion that interrupts are already disabled.  This should
remove the corresponding overhead from the interrupt entry/exit fastpaths.

This change was inspired by the fact that Iftekhar Ahmed's mutation
testing showed that removing rcu_irq_enter()'s call to local_ird_restore()
had no effect, which might indicate that interrupts were always enabled
anyway.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 include/linux/rcupdate.h   |  4 ++--
 include/linux/rcutiny.h    |  8 ++++++++
 include/linux/rcutree.h    |  2 ++
 include/linux/tracepoint.h |  4 ++--
 kernel/rcu/tree.c          | 32 ++++++++++++++++++++++++++------
 5 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index a0189ba67fde..f2b667df1131 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -379,9 +379,9 @@ static inline void rcu_init_nohz(void)
  */
 #define RCU_NONIDLE(a) \
 	do { \
-		rcu_irq_enter(); \
+		rcu_irq_enter_irqson(); \
 		do { a; } while (0); \
-		rcu_irq_exit(); \
+		rcu_irq_exit_irqson(); \
 	} while (0)
 
 /*
diff --git a/include/linux/rcutiny.h b/include/linux/rcutiny.h
index 4c1aaf9cce7b..64809aea661c 100644
--- a/include/linux/rcutiny.h
+++ b/include/linux/rcutiny.h
@@ -181,6 +181,14 @@ static inline void rcu_irq_enter(void)
 {
 }
 
+static inline void rcu_irq_exit_irqson(void)
+{
+}
+
+static inline void rcu_irq_enter_irqson(void)
+{
+}
+
 static inline void rcu_irq_exit(void)
 {
 }
diff --git a/include/linux/rcutree.h b/include/linux/rcutree.h
index 9d3eda39bcd2..ad1eda9fa4da 100644
--- a/include/linux/rcutree.h
+++ b/include/linux/rcutree.h
@@ -97,6 +97,8 @@ void rcu_idle_enter(void);
 void rcu_idle_exit(void);
 void rcu_irq_enter(void);
 void rcu_irq_exit(void);
+void rcu_irq_enter_irqson(void);
+void rcu_irq_exit_irqson(void);
 
 void exit_rcu(void);
 
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 696a339c592c..7834a8a8bf1e 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -171,8 +171,8 @@ extern void syscall_unregfunc(void);
 				TP_PROTO(data_proto),			\
 				TP_ARGS(data_args),			\
 				TP_CONDITION(cond),			\
-				rcu_irq_enter(),			\
-				rcu_irq_exit());			\
+				rcu_irq_enter_irqson(),			\
+				rcu_irq_exit_irqson());			\
 	}
 #else
 #define __DECLARE_TRACE_RCU(name, proto, args, cond, data_proto, data_args)
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index d6863bceeb45..40940b0d0310 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -732,7 +732,7 @@ void rcu_user_enter(void)
  *
  * Exit from an interrupt handler, which might possibly result in entering
  * idle mode, in other words, leaving the mode in which read-side critical
- * sections can occur.
+ * sections can occur.  The caller must have disabled interrupts.
  *
  * This code assumes that the idle loop never does anything that might
  * result in unbalanced calls to irq_enter() and irq_exit().  If your
@@ -745,11 +745,10 @@ void rcu_user_enter(void)
  */
 void rcu_irq_exit(void)
 {
-	unsigned long flags;
 	long long oldval;
 	struct rcu_dynticks *rdtp;
 
-	local_irq_save(flags);
+	RCU_LOCKDEP_WARN(!irqs_disabled(), "rcu_irq_exit() invoked with irqs enabled!!!");
 	rdtp = this_cpu_ptr(&rcu_dynticks);
 	oldval = rdtp->dynticks_nesting;
 	rdtp->dynticks_nesting--;
@@ -760,6 +759,17 @@ void rcu_irq_exit(void)
 	else
 		rcu_eqs_enter_common(oldval, true);
 	rcu_sysidle_enter(1);
+}
+
+/*
+ * Wrapper for rcu_irq_exit() where interrupts are enabled.
+ */
+void rcu_irq_exit_irqson(void)
+{
+	unsigned long flags;
+
+	local_irq_save(flags);
+	rcu_irq_exit();
 	local_irq_restore(flags);
 }
 
@@ -857,7 +867,7 @@ void rcu_user_exit(void)
  *
  * Enter an interrupt handler, which might possibly result in exiting
  * idle mode, in other words, entering the mode in which read-side critical
- * sections can occur.
+ * sections can occur.  The caller must have disabled interrupts.
  *
  * Note that the Linux kernel is fully capable of entering an interrupt
  * handler that it never exits, for example when doing upcalls to
@@ -873,11 +883,10 @@ void rcu_user_exit(void)
  */
 void rcu_irq_enter(void)
 {
-	unsigned long flags;
 	struct rcu_dynticks *rdtp;
 	long long oldval;
 
-	local_irq_save(flags);
+	RCU_LOCKDEP_WARN(!irqs_disabled(), "rcu_irq_enter() invoked with irqs enabled!!!");
 	rdtp = this_cpu_ptr(&rcu_dynticks);
 	oldval = rdtp->dynticks_nesting;
 	rdtp->dynticks_nesting++;
@@ -888,6 +897,17 @@ void rcu_irq_enter(void)
 	else
 		rcu_eqs_exit_common(oldval, true);
 	rcu_sysidle_exit(1);
+}
+
+/*
+ * Wrapper for rcu_irq_enter() where interrupts are enabled.
+ */
+void rcu_irq_enter_irqson(void)
+{
+	unsigned long flags;
+
+	local_irq_save(flags);
+	rcu_irq_enter();
 	local_irq_restore(flags);
 }
 
-- 
2.5.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH tip/core/rcu 11/13] rcu: Fix comment for rcu_dereference_raw_notrace
  2015-12-04 23:58 [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5 Paul E. McKenney
                   ` (9 preceding siblings ...)
  2015-12-05  0:10 ` [PATCH tip/core/rcu 10/13] rcu: Don't redundantly disable irqs in rcu_irq_{enter,exit}() Paul E. McKenney
@ 2015-12-05  0:10 ` Paul E. McKenney
  2015-12-05  0:10 ` [PATCH tip/core/rcu 12/13] rcu: Move wakeup out from under rnp->lock Paul E. McKenney
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Paul E. McKenney @ 2015-12-05  0:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh,
	tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec,
	oleg, bobby.prani, Alexey Kardashevskiy, Paul E. McKenney

From: Alexey Kardashevskiy <aik@ozlabs.ru>

rcu_dereference_raw() calls indirectly rcu_read_lock_held() while
rcu_dereference_raw_notrace() does not so fix the comment about the latter.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 include/linux/rcupdate.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index f2b667df1131..85aabcd8b564 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -741,7 +741,7 @@ static inline void rcu_preempt_sleep_check(void)
  * The tracing infrastructure traces RCU (we want that), but unfortunately
  * some of the RCU checks causes tracing to lock up the system.
  *
- * The tracing version of rcu_dereference_raw() must not call
+ * The no-tracing version of rcu_dereference_raw() must not call
  * rcu_read_lock_held().
  */
 #define rcu_dereference_raw_notrace(p) __rcu_dereference_check((p), 1, __rcu)
-- 
2.5.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH tip/core/rcu 12/13] rcu: Move wakeup out from under rnp->lock
  2015-12-04 23:58 [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5 Paul E. McKenney
                   ` (10 preceding siblings ...)
  2015-12-05  0:10 ` [PATCH tip/core/rcu 11/13] rcu: Fix comment for rcu_dereference_raw_notrace Paul E. McKenney
@ 2015-12-05  0:10 ` Paul E. McKenney
  2015-12-05  0:10 ` [PATCH tip/core/rcu 13/13] rcu: Make rcu_gp_init() be bool rather than int Paul E. McKenney
  2015-12-05  1:06 ` [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5 Josh Triplett
  13 siblings, 0 replies; 16+ messages in thread
From: Paul E. McKenney @ 2015-12-05  0:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh,
	tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec,
	oleg, bobby.prani, Paul E. McKenney

From: Peter Zijlstra <peterz@infradead.org>

This patch removes a potential deadlock hazard by moving the
wake_up_process() in rcu_spawn_gp_kthread() out from under rnp->lock.

Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 kernel/rcu/tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 40940b0d0310..87b604d0b0d2 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -4319,8 +4319,8 @@ static int __init rcu_spawn_gp_kthread(void)
 			sp.sched_priority = kthread_prio;
 			sched_setscheduler_nocheck(t, SCHED_FIFO, &sp);
 		}
-		wake_up_process(t);
 		raw_spin_unlock_irqrestore(&rnp->lock, flags);
+		wake_up_process(t);
 	}
 	rcu_spawn_nocb_kthreads();
 	rcu_spawn_boost_kthreads();
-- 
2.5.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH tip/core/rcu 13/13] rcu: Make rcu_gp_init() be bool rather than int
  2015-12-04 23:58 [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5 Paul E. McKenney
                   ` (11 preceding siblings ...)
  2015-12-05  0:10 ` [PATCH tip/core/rcu 12/13] rcu: Move wakeup out from under rnp->lock Paul E. McKenney
@ 2015-12-05  0:10 ` Paul E. McKenney
  2015-12-05  1:06 ` [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5 Josh Triplett
  13 siblings, 0 replies; 16+ messages in thread
From: Paul E. McKenney @ 2015-12-05  0:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh,
	tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec,
	oleg, bobby.prani, Paul E. McKenney

The return value from rcu_gp_init() is always used as a bool, so
this commit makes it be a bool.

Reported-by: Iftekhar Ahmed <ahmedi@oregonstate.edu>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 kernel/rcu/tree.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 87b604d0b0d2..01a90a3bdf79 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -1814,9 +1814,9 @@ static void rcu_gp_slow(struct rcu_state *rsp, int delay)
 }
 
 /*
- * Initialize a new grace period.  Return 0 if no grace period required.
+ * Initialize a new grace period.  Return false if no grace period required.
  */
-static int rcu_gp_init(struct rcu_state *rsp)
+static bool rcu_gp_init(struct rcu_state *rsp)
 {
 	unsigned long oldmask;
 	struct rcu_data *rdp;
@@ -1827,7 +1827,7 @@ static int rcu_gp_init(struct rcu_state *rsp)
 	if (!READ_ONCE(rsp->gp_flags)) {
 		/* Spurious wakeup, tell caller to go back to sleep.  */
 		raw_spin_unlock_irq(&rnp->lock);
-		return 0;
+		return false;
 	}
 	WRITE_ONCE(rsp->gp_flags, 0); /* Clear all flags: New grace period. */
 
@@ -1837,7 +1837,7 @@ static int rcu_gp_init(struct rcu_state *rsp)
 		 * Not supposed to be able to happen.
 		 */
 		raw_spin_unlock_irq(&rnp->lock);
-		return 0;
+		return false;
 	}
 
 	/* Advance to a new grace period and initialize state. */
@@ -1929,7 +1929,7 @@ static int rcu_gp_init(struct rcu_state *rsp)
 		WRITE_ONCE(rsp->gp_activity, jiffies);
 	}
 
-	return 1;
+	return true;
 }
 
 /*
-- 
2.5.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5
  2015-12-04 23:58 [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5 Paul E. McKenney
                   ` (12 preceding siblings ...)
  2015-12-05  0:10 ` [PATCH tip/core/rcu 13/13] rcu: Make rcu_gp_init() be bool rather than int Paul E. McKenney
@ 2015-12-05  1:06 ` Josh Triplett
  2015-12-06  2:27   ` Paul E. McKenney
  13 siblings, 1 reply; 16+ messages in thread
From: Josh Triplett @ 2015-12-05  1:06 UTC (permalink / raw)
  To: Paul E. McKenney
  Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm,
	mathieu.desnoyers, tglx, peterz, rostedt, dhowells, edumazet,
	dvhart, fweisbec, oleg, bobby.prani

On Fri, Dec 04, 2015 at 03:58:51PM -0800, Paul E. McKenney wrote:
> Hello!
> 
> This series contains follow-on cleanup changes to RCU's expedited
> grace-period functionality.  The patches in this series are as follows:
> 
> 1.	Short-circuit synchronize_sched_expedited() if there is only one CPU.
> 
> 2.	Update comment to clarify the role of ->expmaskinitnext.
> 
> 3.	Separate concerns by moving smp_mb() from rcu_seq_snap() to
> 	rcu_exp_gp_seq_snap().
> 
> 4.	Safe a few lines of code by inverting the sense of
> 	sync_rcu_exp_select_cpus() "if" statement.
> 
> 5.	Reduce expedited GP memory contention via per-CPU variables.
> 
> 6.	Get rid of (some) empty stall-warning messages by resolving
> 	stall-warning ties.
> 
> 7.	Add more diagnostics to expedited stall warning messages.
> 
> 8.	Add rcu_normal kernel parameter to suppress expediting for
> 	the benefit of aggressive real-time systems.
> 
> 9-10.	Allow expedited grace periods to be disabled just before init
> 	is spawned, allowing them to speed up boot without interfering
> 	with run-time real-time workloads.

This cover letter doesn't seem to match the patch series that shows up
as replies to it.  The patch series has 13 patches, numbered 01/13 to
13/13.  You sent a separate cover letter, not part of this thread, that
seems to match up.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5
  2015-12-05  1:06 ` [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5 Josh Triplett
@ 2015-12-06  2:27   ` Paul E. McKenney
  0 siblings, 0 replies; 16+ messages in thread
From: Paul E. McKenney @ 2015-12-06  2:27 UTC (permalink / raw)
  To: Josh Triplett
  Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm,
	mathieu.desnoyers, tglx, peterz, rostedt, dhowells, edumazet,
	dvhart, fweisbec, oleg, bobby.prani

On Fri, Dec 04, 2015 at 05:06:42PM -0800, Josh Triplett wrote:
> On Fri, Dec 04, 2015 at 03:58:51PM -0800, Paul E. McKenney wrote:
> > Hello!
> > 
> > This series contains follow-on cleanup changes to RCU's expedited
> > grace-period functionality.  The patches in this series are as follows:
> > 
> > 1.	Short-circuit synchronize_sched_expedited() if there is only one CPU.
> > 
> > 2.	Update comment to clarify the role of ->expmaskinitnext.
> > 
> > 3.	Separate concerns by moving smp_mb() from rcu_seq_snap() to
> > 	rcu_exp_gp_seq_snap().
> > 
> > 4.	Safe a few lines of code by inverting the sense of
> > 	sync_rcu_exp_select_cpus() "if" statement.
> > 
> > 5.	Reduce expedited GP memory contention via per-CPU variables.
> > 
> > 6.	Get rid of (some) empty stall-warning messages by resolving
> > 	stall-warning ties.
> > 
> > 7.	Add more diagnostics to expedited stall warning messages.
> > 
> > 8.	Add rcu_normal kernel parameter to suppress expediting for
> > 	the benefit of aggressive real-time systems.
> > 
> > 9-10.	Allow expedited grace periods to be disabled just before init
> > 	is spawned, allowing them to speed up boot without interfering
> > 	with run-time real-time workloads.
> 
> This cover letter doesn't seem to match the patch series that shows up
> as replies to it.  The patch series has 13 patches, numbered 01/13 to
> 13/13.  You sent a separate cover letter, not part of this thread, that
> seems to match up.

Indeed, not one of my better patch submissions.  :-/

							Thanx, Paul


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-12-06  2:26 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-04 23:58 [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5 Paul E. McKenney
2015-12-05  0:10 ` [PATCH tip/core/rcu 01/13] rcu: Move lock_class_key to local scope Paul E. McKenney
2015-12-05  0:10 ` [PATCH tip/core/rcu 02/13] kernel: Make rcu/tree_trace.c explicitly non-modular Paul E. McKenney
2015-12-05  0:10 ` [PATCH tip/core/rcu 03/13] rcu: Simplify rcu_sched_qs() control flow Paul E. McKenney
2015-12-05  0:10 ` [PATCH tip/core/rcu 04/13] rcu: Remove lock-acquisition loop from rcu_read_unlock_special() Paul E. McKenney
2015-12-05  0:10 ` [PATCH tip/core/rcu 05/13] rcu: Fix obsolete rcu_bootup_announce_oddness() comment Paul E. McKenney
2015-12-05  0:10 ` [PATCH tip/core/rcu 06/13] rcu: Avoid tick_nohz_active checks on NOCBs CPUs Paul E. McKenney
2015-12-05  0:10 ` [PATCH tip/core/rcu 07/13] rcu: Stop disabling interrupts in scheduler fastpaths Paul E. McKenney
2015-12-05  0:10 ` [PATCH tip/core/rcu 08/13] rcu: Eliminate unused rcu_init_one() argument Paul E. McKenney
2015-12-05  0:10 ` [PATCH tip/core/rcu 09/13] rcu: Make cpu_needs_another_gp() be bool Paul E. McKenney
2015-12-05  0:10 ` [PATCH tip/core/rcu 10/13] rcu: Don't redundantly disable irqs in rcu_irq_{enter,exit}() Paul E. McKenney
2015-12-05  0:10 ` [PATCH tip/core/rcu 11/13] rcu: Fix comment for rcu_dereference_raw_notrace Paul E. McKenney
2015-12-05  0:10 ` [PATCH tip/core/rcu 12/13] rcu: Move wakeup out from under rnp->lock Paul E. McKenney
2015-12-05  0:10 ` [PATCH tip/core/rcu 13/13] rcu: Make rcu_gp_init() be bool rather than int Paul E. McKenney
2015-12-05  1:06 ` [PATCH tip/core/rcu 0/10] Expedited-grace-period changes for 4.5 Josh Triplett
2015-12-06  2:27   ` Paul E. McKenney

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).