[PATCH 05/32] nohz: Move rcu dynticks idle mode handling to idle enter/exit APIs

Frederic Weisbecker
2011-08-15T15:53:01Z

To prepare for nohz / idle logic split, pull out the rcu dynticks
idle mode switching to strict idle entry/exit areas.

So we make the dyntick mode possible without always involving rcu
extended quiescent state.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Anton Blanchard <anton@au1.ibm.com>
Cc: Avi Kivity <avi@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Paul E . McKenney <paulmck@linux.vnet.ibm.com>
Cc: Paul Menage <menage@google.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephen Hemminger <shemminger@vyatta.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tim Pepper <lnxninja@linux.vnet.ibm.com>
---
kernel/time/tick-sched.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index df6bb4c..8937d4a 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -385,7 +385,6 @@ static void tick_nohz_stop_sched_tick(ktime_t now)
ts->idle_tick = hrtimer_get_expires(&ts->sched_timer);
ts->tick_stopped = 1;
ts->idle_jiffies = last_jiffies;
- rcu_enter_nohz();
}

ts->idle_sleeps++;
@@ -429,9 +428,13 @@ out:
static void __tick_nohz_enter_idle(struct tick_sched *ts, int cpu)
{
ktime_t now;
+ int was_stopped = ts->tick_stopped;

now = tick_nohz_start_idle(cpu, ts);
tick_nohz_stop_sched_tick(now);
+
+ if (!was_stopped && ts->tick_stopped)
+ rcu_enter_nohz();
}

void tick_nohz_enter_idle(void)
@@ -499,8 +502,6 @@ static void tick_nohz_restart_sched_tick(ktime_t now, struct tick_sched *ts)
unsigned long ticks;
#endif

- rcu_exit_nohz();
-
/* Update jiffies first */
select_nohz_load_balancer(0);
tick_do_update_jiffies64(now);
@@ -547,8 +548,10 @@ void tick_nohz_exit_idle(void)
tick_nohz_stop_idle(smp_processor_id(), now);
ts->inidle = 0;

- if (ts->tick_stopped)
+ if (ts->tick_stopped) {
+ rcu_exit_nohz();
tick_nohz_restart_sched_tick(now, ts);
+ }

local_irq_enable();
}
--
1.7.5.4