[PATCH RFC idle 3/3] sh: Avoid invoking RCU when CPU is idle

From: Paul E. McKenney
Date: Wed Feb 01 2012 - 19:43:36 EST


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

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@xxxxxxxxxx>
Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
Cc: Paul Mundt <lethal@xxxxxxxxxxxx>
Cc: Mike Frysinger <vapier@xxxxxxxxxx>
Cc: linux-sh@xxxxxxxxxxxxxxx
---
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/