linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC idle 3/3] sh: Avoid invoking RCU when CPU is idle
       [not found] ` <1328143404-11038-1-git-send-email-paulmck@linux.vnet.ibm.com>
@ 2012-02-02  0:43   ` Paul E. McKenney
  0 siblings, 0 replies; only message in thread
From: Paul E. McKenney @ 2012-02-02  0:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, laijs, dipankar, akpm, mathieu.desnoyers, josh, niv, tglx,
	peterz, rostedt, Valdis.Kletnieks, dhowells, eric.dumazet, darren,
	fweisbec, patches, Paul E. McKenney, Paul E. McKenney, Paul Mundt,
	Mike Frysinger, linux-sh

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

The idle loop is a quiscent state for RCU, which means that RCU ignores
CPUs that have told RCU that they are idle via rcu_idle_enter().
There are nevertheless quite a few places where idle CPUs use RCU, most
commonly indirectly via tracing.  This patch fixes these problems for SH.

Many of these bugs have been in the kernel for quite some time, but
Frederic's recent change now gives warnings.

This patch takes the straightforward approach of pushing the
rcu_idle_enter()/rcu_idle_exit() pair further down into the core of the
idle loop.

Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: linux-sh@vger.kernel.org
---
 arch/sh/kernel/idle.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/sh/kernel/idle.c b/arch/sh/kernel/idle.c
index 406508d..d125668 100644
--- a/arch/sh/kernel/idle.c
+++ b/arch/sh/kernel/idle.c
@@ -53,8 +53,10 @@ static inline int hlt_works(void)
 static void poll_idle(void)
 {
 	local_irq_enable();
+	rcu_idle_enter();
 	while (!need_resched())
 		cpu_relax();
+	rcu_idle_exit();
 }
 
 void default_idle(void)
@@ -66,9 +68,14 @@ void default_idle(void)
 		set_bl_bit();
 		if (!need_resched()) {
 			local_irq_enable();
+			rcu_idle_enter();
 			cpu_sleep();
-		} else
+			rcu_idle_exit();
+		} else {
 			local_irq_enable();
+			rcu_idle_enter();
+			rcu_idle_exit();
+		}
 
 		set_thread_flag(TIF_POLLING_NRFLAG);
 		clear_bl_bit();
@@ -90,7 +97,6 @@ void cpu_idle(void)
 	/* endless idle loop with no priority at all */
 	while (1) {
 		tick_nohz_idle_enter();
-		rcu_idle_enter();
 
 		while (!need_resched()) {
 			check_pgt_cache();
@@ -112,7 +118,6 @@ void cpu_idle(void)
 			start_critical_timings();
 		}
 
-		rcu_idle_exit();
 		tick_nohz_idle_exit();
 		preempt_enable_no_resched();
 		schedule();
-- 
1.7.8


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-02-02  0:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20120202004253.GA10946@linux.vnet.ibm.com>
     [not found] ` <1328143404-11038-1-git-send-email-paulmck@linux.vnet.ibm.com>
2012-02-02  0:43   ` [PATCH RFC idle 3/3] sh: Avoid invoking RCU when CPU is idle 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).