Skip to contentSkip to conversation

Idle changes for 3.8

PATCH New Paul E. McKenney 1 participant 6 messages Oct 30, 2012

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Idle changes for 3.8

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(-)
#1 lore raw

PATCH 1/5 rcu: Remove rcu_switch()

From: Frederic Weisbecker <[email protected]>

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.

Cc Josh Triplett <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Richard Weinberger <[email protected]>
---
 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(-)
arch/um/drivers/mconsole_kern.c +1 -1
index 79ccfe6..49e3b49 100644
@@ -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);
 }
 
include/linux/rcupdate.h +2 -0
index 7c968e4..5d009de 100644
@@ -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);
include/linux/sched.h +0 -8
index 0dd42a0..432cc5e 100644
@@ -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)
 {
kernel/sched/core.c +1 -1
index 2d8927f..68414fa 100644
@@ -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();
Signature · 1 line
1.7.8
#2 lore raw

PATCH 2/5 rcu: Update RCU_FAST_NO_HZ help text

From: "Paul E. McKenney" <[email protected]>

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.

---
 init/Kconfig |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)
init/Kconfig +7 -8
index 6fdd6e3..b63e798 100644
@@ -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.
 
Signature · 1 line
1.7.8
#3 lore raw

PATCH 3/5 rcu: Add a module parameter to force use of expedited RCU primitives

In reply to Paul E. McKenney

From: Antti P Miettinen <[email protected]>

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

---
 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(-)
kernel/ksysfs.c +18 -0
index 4e316e1..8715a79 100644
@@ -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
 };
 
kernel/rcu.h +2 -0
index 8ba99cd..20dfba5 100644
@@ -109,4 +109,6 @@ static inline bool __rcu_reclaim(char *rn, struct rcu_head *head)
 	}
 }
 
+extern int rcu_expedited;
+
 #endif /* __LINUX_RCU_H */
kernel/rcupdate.c +3 -0
index 29ca1c6..a2cf761 100644
@@ -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
 
 /*
kernel/rcutiny_plugin.h +4 -1
index 3d01902..f85016a 100644
@@ -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);
 
kernel/rcutree.c +9 -3
index 74df86b..f9c17c3 100644
@@ -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;
 		}
 
kernel/rcutree_plugin.h +5 -2
index f921154..c177ba0 100644
@@ -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;
 		}
 	}
kernel/srcu.c +7 -1
index 97c465e..de90740 100644
@@ -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);
 
Signature · 1 line
1.7.8
#4 lore raw

PATCH 4/5 rcu: Fix precedence error in cpu_needs_another_gp()

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

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.

---
 kernel/rcutree.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/rcutree.c +1 -1
index f9c17c3..effd47a 100644
@@ -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);
 }
 
Signature · 1 line
1.7.8
#5 lore raw

PATCH 5/5 rcu: Wordsmith help text for RCU_USER_QS kernel parameter

In reply to Paul E. McKenney

From: Paul Gortmaker <[email protected]>

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

---
 init/Kconfig |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
init/Kconfig +3 -3
index b63e798..ec62139 100644
@@ -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
 
Signature · 1 line
1.7.8