mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH tip/core/rcu 0/5] Idle changes for 3.8
@ 2012-10-30 17:19 Paul E. McKenney
  2012-10-30 17:19 ` [PATCH tip/core/rcu 1/5] rcu: Remove rcu_switch() Paul E. McKenney
  0 siblings, 1 reply; 6+ messages in thread
From: Paul E. McKenney @ 2012-10-30 17:19 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, laijs, dipankar, akpm, mathieu.desnoyers, josh, niv, tglx,
	peterz, rostedt, Valdis.Kletnieks, dhowells, edumazet, darren,
	fweisbec, sbw, patches

Hello!

This patch series contains changes to RCU's interaction with idle.
The individual patches are as follows:

1.	Remove a layer of indirection to rcu_user_hooks_switch().
	(Courtesy of Frederic Weisbecker.)
2.	Update RCU_FAST_NO_HZ help text to remove the warning about
	running on large systems.
3.	Add "rcu_expedited" boot and sysfs parameters that cause the
	kernel to substitute expedited primitives for the normal
	grace period primitives.  (Courtesy of Antti P Miettinen.)
4.	Fix a precedence error in cpu_needs_another_gp() that
	surprisingly had no effect -- but clarity is good.
5.	Fix grammar issue in RCU_USER_QS help text.  (Courtesy of
	Paul Gortmaker.)

							Thanx, Paul

 b/arch/um/drivers/mconsole_kern.c |    2 +-
 b/include/linux/rcupdate.h        |    2 ++
 b/include/linux/sched.h           |    8 --------
 b/init/Kconfig                    |   15 +++++++--------
 b/kernel/ksysfs.c                 |   18 ++++++++++++++++++
 b/kernel/rcu.h                    |    2 ++
 b/kernel/rcupdate.c               |    3 +++
 b/kernel/rcutiny_plugin.h         |    5 ++++-
 b/kernel/rcutree.c                |   12 +++++++++---
 b/kernel/rcutree_plugin.h         |    7 +++++--
 b/kernel/sched/core.c             |    2 +-
 b/kernel/srcu.c                   |    8 +++++++-
 init/Kconfig                      |    6 +++---
 kernel/rcutree.c                  |    2 +-
 14 files changed, 63 insertions(+), 29 deletions(-)


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

* [PATCH tip/core/rcu 1/5] rcu: Remove rcu_switch()
  2012-10-30 17:19 [PATCH tip/core/rcu 0/5] Idle changes for 3.8 Paul E. McKenney
@ 2012-10-30 17:19 ` Paul E. McKenney
  2012-10-30 17:19   ` [PATCH tip/core/rcu 2/5] rcu: Update RCU_FAST_NO_HZ help text Paul E. McKenney
                     ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Paul E. McKenney @ 2012-10-30 17:19 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, laijs, dipankar, akpm, mathieu.desnoyers, josh, niv, tglx,
	peterz, rostedt, Valdis.Kletnieks, dhowells, edumazet, darren,
	fweisbec, sbw, patches, Richard Weinberger, Paul E. McKenney

From: Frederic Weisbecker <fweisbec@gmail.com>

It's only there to call rcu_user_hooks_switch(). Let's
just call rcu_user_hooks_switch() directly, we don't need this
function in the middle.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Richard Weinberger <richard@nod.at>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 arch/um/drivers/mconsole_kern.c |    2 +-
 include/linux/rcupdate.h        |    2 ++
 include/linux/sched.h           |    8 --------
 kernel/sched/core.c             |    2 +-
 4 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 79ccfe6..49e3b49 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -648,7 +648,7 @@ static void stack_proc(void *arg)
 	struct task_struct *from = current, *to = arg;
 
 	to->thread.saved_task = from;
-	rcu_switch(from, to);
+	rcu_user_hooks_switch(from, to);
 	switch_to(from, to, from);
 }
 
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 7c968e4..5d009de 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -204,6 +204,8 @@ static inline void rcu_user_enter(void) { }
 static inline void rcu_user_exit(void) { }
 static inline void rcu_user_enter_after_irq(void) { }
 static inline void rcu_user_exit_after_irq(void) { }
+static inline void rcu_user_hooks_switch(struct task_struct *prev,
+					 struct task_struct *next) { }
 #endif /* CONFIG_RCU_USER_QS */
 
 extern void exit_rcu(void);
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 0dd42a0..432cc5e 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1844,14 +1844,6 @@ static inline void rcu_copy_process(struct task_struct *p)
 
 #endif
 
-static inline void rcu_switch(struct task_struct *prev,
-			      struct task_struct *next)
-{
-#ifdef CONFIG_RCU_USER_QS
-	rcu_user_hooks_switch(prev, next);
-#endif
-}
-
 static inline void tsk_restore_flags(struct task_struct *task,
 				unsigned long orig_flags, unsigned long flags)
 {
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 2d8927f..68414fa 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1887,7 +1887,7 @@ context_switch(struct rq *rq, struct task_struct *prev,
 #endif
 
 	/* Here we just switch the register state and the stack. */
-	rcu_switch(prev, next);
+	rcu_user_hooks_switch(prev, next);
 	switch_to(prev, next, prev);
 
 	barrier();
-- 
1.7.8


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

* [PATCH tip/core/rcu 2/5] rcu: Update RCU_FAST_NO_HZ help text
  2012-10-30 17:19 ` [PATCH tip/core/rcu 1/5] rcu: Remove rcu_switch() Paul E. McKenney
@ 2012-10-30 17:19   ` Paul E. McKenney
  2012-10-30 17:19   ` [PATCH tip/core/rcu 3/5] rcu: Add a module parameter to force use of expedited RCU primitives Paul E. McKenney
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Paul E. McKenney @ 2012-10-30 17:19 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, laijs, dipankar, akpm, mathieu.desnoyers, josh, niv, tglx,
	peterz, rostedt, Valdis.Kletnieks, dhowells, edumazet, darren,
	fweisbec, sbw, patches, Paul E. McKenney, Paul E. McKenney

From: "Paul E. McKenney" <paul.mckenney@linaro.org>

The RCU_FAST_NO_HZ help text included a warning about overhead on large
systems, but that issue has since been resolved.  The main remaining
issue with RCU_FAST_NO_HZ is increased real-time latency.  This commit
therefore updates the help text accordingly.

Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 init/Kconfig |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/init/Kconfig b/init/Kconfig
index 6fdd6e3..b63e798 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -582,14 +582,13 @@ config RCU_FAST_NO_HZ
 	depends on NO_HZ && SMP
 	default n
 	help
-	  This option causes RCU to attempt to accelerate grace periods
-	  in order to allow CPUs to enter dynticks-idle state more
-	  quickly.  On the other hand, this option increases the overhead
-	  of the dynticks-idle checking, particularly on systems with
-	  large numbers of CPUs.
-
-	  Say Y if energy efficiency is critically important, particularly
-	  	if you have relatively few CPUs.
+	  This option causes RCU to attempt to accelerate grace periods in
+	  order to allow CPUs to enter dynticks-idle state more quickly.
+	  On the other hand, this option increases the overhead of the
+	  dynticks-idle checking, thus degrading scheduling latency.
+
+	  Say Y if energy efficiency is critically important, and you don't
+	  	care about real-time response.
 
 	  Say N if you are unsure.
 
-- 
1.7.8


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

* [PATCH tip/core/rcu 3/5] rcu: Add a module parameter to force use of expedited RCU primitives
  2012-10-30 17:19 ` [PATCH tip/core/rcu 1/5] rcu: Remove rcu_switch() Paul E. McKenney
  2012-10-30 17:19   ` [PATCH tip/core/rcu 2/5] rcu: Update RCU_FAST_NO_HZ help text Paul E. McKenney
@ 2012-10-30 17:19   ` Paul E. McKenney
  2012-10-30 17:19   ` [PATCH tip/core/rcu 4/5] rcu: Fix precedence error in cpu_needs_another_gp() Paul E. McKenney
  2012-10-30 17:19   ` [PATCH tip/core/rcu 5/5] rcu: Wordsmith help text for RCU_USER_QS kernel parameter Paul E. McKenney
  3 siblings, 0 replies; 6+ messages in thread
From: Paul E. McKenney @ 2012-10-30 17:19 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, laijs, dipankar, akpm, mathieu.desnoyers, josh, niv, tglx,
	peterz, rostedt, Valdis.Kletnieks, dhowells, edumazet, darren,
	fweisbec, sbw, patches, Antti P Miettinen, Antti P Miettinen,
	Paul E. McKenney

From: Antti P Miettinen <ananaza@iki.fi>

There have been some embedded applications that would benefit from
use of expedited grace-period primitives.  In some ways, this is
similar to synchronize_net() doing either a normal or an expedited
grace period depending on lock state, but with control outside of
the kernel.

This commit therefore adds rcu_expedited boot and sysfs parameters
that cause the kernel to substitute expedited primitives for the
normal grace-period primitives.

[ paulmck: Add trace/event/rcu.h to kernel/srcu.c to avoid build error.
	   Get rid of infinite loop through contention path.]

Signed-off-by: Antti P Miettinen <amiettinen@nvidia.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 kernel/ksysfs.c         |   18 ++++++++++++++++++
 kernel/rcu.h            |    2 ++
 kernel/rcupdate.c       |    3 +++
 kernel/rcutiny_plugin.h |    5 ++++-
 kernel/rcutree.c        |   12 +++++++++---
 kernel/rcutree_plugin.h |    7 +++++--
 kernel/srcu.c           |    8 +++++++-
 7 files changed, 48 insertions(+), 7 deletions(-)

diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index 4e316e1..8715a79 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -141,6 +141,23 @@ static ssize_t fscaps_show(struct kobject *kobj,
 }
 KERNEL_ATTR_RO(fscaps);
 
+int rcu_expedited;
+static ssize_t rcu_expedited_show(struct kobject *kobj,
+				  struct kobj_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%d\n", rcu_expedited);
+}
+static ssize_t rcu_expedited_store(struct kobject *kobj,
+				   struct kobj_attribute *attr,
+				   const char *buf, size_t count)
+{
+	if (kstrtoint(buf, 0, &rcu_expedited))
+		return -EINVAL;
+
+	return count;
+}
+KERNEL_ATTR_RW(rcu_expedited);
+
 /*
  * Make /sys/kernel/notes give the raw contents of our kernel .notes section.
  */
@@ -182,6 +199,7 @@ static struct attribute * kernel_attrs[] = {
 	&kexec_crash_size_attr.attr,
 	&vmcoreinfo_attr.attr,
 #endif
+	&rcu_expedited_attr.attr,
 	NULL
 };
 
diff --git a/kernel/rcu.h b/kernel/rcu.h
index 8ba99cd..20dfba5 100644
--- a/kernel/rcu.h
+++ b/kernel/rcu.h
@@ -109,4 +109,6 @@ static inline bool __rcu_reclaim(char *rn, struct rcu_head *head)
 	}
 }
 
+extern int rcu_expedited;
+
 #endif /* __LINUX_RCU_H */
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
index 29ca1c6..a2cf761 100644
--- a/kernel/rcupdate.c
+++ b/kernel/rcupdate.c
@@ -46,12 +46,15 @@
 #include <linux/export.h>
 #include <linux/hardirq.h>
 #include <linux/delay.h>
+#include <linux/module.h>
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/rcu.h>
 
 #include "rcu.h"
 
+module_param(rcu_expedited, int, 0);
+
 #ifdef CONFIG_PREEMPT_RCU
 
 /*
diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
index 3d01902..f85016a 100644
--- a/kernel/rcutiny_plugin.h
+++ b/kernel/rcutiny_plugin.h
@@ -706,7 +706,10 @@ void synchronize_rcu(void)
 		return;
 
 	/* Once we get past the fastpath checks, same code as rcu_barrier(). */
-	rcu_barrier();
+	if (rcu_expedited)
+		synchronize_rcu_expedited();
+	else
+		rcu_barrier();
 }
 EXPORT_SYMBOL_GPL(synchronize_rcu);
 
diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index 74df86b..f9c17c3 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -2224,7 +2224,10 @@ void synchronize_sched(void)
 			   "Illegal synchronize_sched() in RCU-sched read-side critical section");
 	if (rcu_blocking_is_gp())
 		return;
-	wait_rcu_gp(call_rcu_sched);
+	if (rcu_expedited)
+		synchronize_sched_expedited();
+	else
+		wait_rcu_gp(call_rcu_sched);
 }
 EXPORT_SYMBOL_GPL(synchronize_sched);
 
@@ -2245,7 +2248,10 @@ void synchronize_rcu_bh(void)
 			   "Illegal synchronize_rcu_bh() in RCU-bh read-side critical section");
 	if (rcu_blocking_is_gp())
 		return;
-	wait_rcu_gp(call_rcu_bh);
+	if (rcu_expedited)
+		synchronize_rcu_bh_expedited();
+	else
+		wait_rcu_gp(call_rcu_bh);
 }
 EXPORT_SYMBOL_GPL(synchronize_rcu_bh);
 
@@ -2328,7 +2334,7 @@ void synchronize_sched_expedited(void)
 		if (trycount++ < 10) {
 			udelay(trycount * num_online_cpus());
 		} else {
-			synchronize_sched();
+			wait_rcu_gp(call_rcu_sched);
 			return;
 		}
 
diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
index f921154..c177ba0 100644
--- a/kernel/rcutree_plugin.h
+++ b/kernel/rcutree_plugin.h
@@ -679,7 +679,10 @@ void synchronize_rcu(void)
 			   "Illegal synchronize_rcu() in RCU read-side critical section");
 	if (!rcu_scheduler_active)
 		return;
-	wait_rcu_gp(call_rcu);
+	if (rcu_expedited)
+		synchronize_rcu_expedited();
+	else
+		wait_rcu_gp(call_rcu);
 }
 EXPORT_SYMBOL_GPL(synchronize_rcu);
 
@@ -831,7 +834,7 @@ void synchronize_rcu_expedited(void)
 			udelay(trycount * num_online_cpus());
 		} else {
 			put_online_cpus();
-			synchronize_rcu();
+			wait_rcu_gp(call_rcu);
 			return;
 		}
 	}
diff --git a/kernel/srcu.c b/kernel/srcu.c
index 97c465e..de90740 100644
--- a/kernel/srcu.c
+++ b/kernel/srcu.c
@@ -34,6 +34,10 @@
 #include <linux/delay.h>
 #include <linux/srcu.h>
 
+#include <trace/events/rcu.h>
+
+#include "rcu.h"
+
 /*
  * Initialize an rcu_batch structure to empty.
  */
@@ -464,7 +468,9 @@ static void __synchronize_srcu(struct srcu_struct *sp, int trycount)
  */
 void synchronize_srcu(struct srcu_struct *sp)
 {
-	__synchronize_srcu(sp, SYNCHRONIZE_SRCU_TRYCOUNT);
+	__synchronize_srcu(sp, rcu_expedited
+			   ? SYNCHRONIZE_SRCU_EXP_TRYCOUNT
+			   : SYNCHRONIZE_SRCU_TRYCOUNT);
 }
 EXPORT_SYMBOL_GPL(synchronize_srcu);
 
-- 
1.7.8


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

* [PATCH tip/core/rcu 4/5] rcu: Fix precedence error in cpu_needs_another_gp()
  2012-10-30 17:19 ` [PATCH tip/core/rcu 1/5] rcu: Remove rcu_switch() Paul E. McKenney
  2012-10-30 17:19   ` [PATCH tip/core/rcu 2/5] rcu: Update RCU_FAST_NO_HZ help text Paul E. McKenney
  2012-10-30 17:19   ` [PATCH tip/core/rcu 3/5] rcu: Add a module parameter to force use of expedited RCU primitives Paul E. McKenney
@ 2012-10-30 17:19   ` Paul E. McKenney
  2012-10-30 17:19   ` [PATCH tip/core/rcu 5/5] rcu: Wordsmith help text for RCU_USER_QS kernel parameter Paul E. McKenney
  3 siblings, 0 replies; 6+ messages in thread
From: Paul E. McKenney @ 2012-10-30 17:19 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, laijs, dipankar, akpm, mathieu.desnoyers, josh, niv, tglx,
	peterz, rostedt, Valdis.Kletnieks, dhowells, edumazet, darren,
	fweisbec, sbw, patches, Paul E. McKenney, Paul E. McKenney

From: "Paul E. McKenney" <paul.mckenney@linaro.org>

The fix introduced by a10d206e (rcu: Fix day-one dyntick-idle
stall-warning bug) has a C-language precedence error.  It turns out
that this error is harmless in that the same result is computed for all
inputs, but the code is nevertheless a potential source of confusion.
This commit therefore introduces parentheses in order to force the
execution of the code to reflect the intent.

Reported-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 kernel/rcutree.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index f9c17c3..effd47a 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -313,7 +313,7 @@ static int
 cpu_needs_another_gp(struct rcu_state *rsp, struct rcu_data *rdp)
 {
 	return *rdp->nxttail[RCU_DONE_TAIL +
-			     ACCESS_ONCE(rsp->completed) != rdp->completed] &&
+			     (ACCESS_ONCE(rsp->completed) != rdp->completed)] &&
 	       !rcu_gp_in_progress(rsp);
 }
 
-- 
1.7.8


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

* [PATCH tip/core/rcu 5/5] rcu: Wordsmith help text for RCU_USER_QS kernel parameter
  2012-10-30 17:19 ` [PATCH tip/core/rcu 1/5] rcu: Remove rcu_switch() Paul E. McKenney
                     ` (2 preceding siblings ...)
  2012-10-30 17:19   ` [PATCH tip/core/rcu 4/5] rcu: Fix precedence error in cpu_needs_another_gp() Paul E. McKenney
@ 2012-10-30 17:19   ` Paul E. McKenney
  3 siblings, 0 replies; 6+ messages in thread
From: Paul E. McKenney @ 2012-10-30 17:19 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, laijs, dipankar, akpm, mathieu.desnoyers, josh, niv, tglx,
	peterz, rostedt, Valdis.Kletnieks, dhowells, edumazet, darren,
	fweisbec, sbw, patches, Paul Gortmaker, Paul E. McKenney

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

This commit adds a "try" missing from the end of the first paragraph
of the RCU_USER_QS help text.

[ paulmck: Also fix up the last paragraph a bit. ]

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 init/Kconfig |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/init/Kconfig b/init/Kconfig
index b63e798..ec62139 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -494,11 +494,11 @@ config RCU_USER_QS
 	  puts RCU in extended quiescent state when the CPU runs in
 	  userspace. It means that when a CPU runs in userspace, it is
 	  excluded from the global RCU state machine and thus doesn't
-	  to keep the timer tick on for RCU.
+	  try to keep the timer tick on for RCU.
 
 	  Unless you want to hack and help the development of the full
-	  tickless feature, you shouldn't enable this option. It adds
-	  unnecessary overhead.
+	  tickless feature, you shouldn't enable this option.  It also
+	  adds unnecessary overhead.
 
 	  If unsure say N
 
-- 
1.7.8


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

end of thread, other threads:[~2012-10-30 17:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-30 17:19 [PATCH tip/core/rcu 0/5] Idle changes for 3.8 Paul E. McKenney
2012-10-30 17:19 ` [PATCH tip/core/rcu 1/5] rcu: Remove rcu_switch() Paul E. McKenney
2012-10-30 17:19   ` [PATCH tip/core/rcu 2/5] rcu: Update RCU_FAST_NO_HZ help text Paul E. McKenney
2012-10-30 17:19   ` [PATCH tip/core/rcu 3/5] rcu: Add a module parameter to force use of expedited RCU primitives Paul E. McKenney
2012-10-30 17:19   ` [PATCH tip/core/rcu 4/5] rcu: Fix precedence error in cpu_needs_another_gp() Paul E. McKenney
2012-10-30 17:19   ` [PATCH tip/core/rcu 5/5] rcu: Wordsmith help text for RCU_USER_QS kernel parameter 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

Powered by JetHome