[RFC PATCH 03/15] nohz_task: Make tick stop and restart callable outside idle

From: Frederic Weisbecker
Date: Mon Dec 20 2010 - 10:24:47 EST


Make the nohz tick restart and stop APIs callable outside idle
and from interrupts.

Don't reenable interrupts unconditionally and only enter/exit
rcu quiescent state if we are in idle.

Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Anton Blanchard <anton@xxxxxxxxxxx>
Cc: Tim Pepper <lnxninja@xxxxxxxxxxxxxxxxxx>
---
kernel/time/tick-sched.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 3e216e0..e706fa8 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -405,12 +405,14 @@ void tick_nohz_stop_sched_tick(int inidle)
* the scheduler tick in nohz_restart_sched_tick.
*/
if (!ts->tick_stopped) {
- select_nohz_load_balancer(1);
+ if (!current->pid)
+ select_nohz_load_balancer(1);

ts->idle_tick = hrtimer_get_expires(&ts->sched_timer);
ts->tick_stopped = 1;
ts->idle_jiffies = last_jiffies;
- rcu_enter_nohz();
+ if (!current->pid)
+ rcu_enter_nohz();
}

ts->idle_sleeps++;
@@ -500,12 +502,14 @@ void tick_nohz_restart_sched_tick(void)
{
int cpu = smp_processor_id();
struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
+ unsigned long flags;
#ifndef CONFIG_VIRT_CPU_ACCOUNTING
unsigned long ticks;
#endif
ktime_t now;

- local_irq_disable();
+ local_irq_save(flags);
+
if (ts->idle_active || (ts->inidle && ts->tick_stopped))
now = ktime_get();

@@ -514,13 +518,14 @@ void tick_nohz_restart_sched_tick(void)

if (!ts->inidle || !ts->tick_stopped) {
ts->inidle = 0;
- local_irq_enable();
+ local_irq_restore(flags);
return;
}

ts->inidle = 0;

- rcu_exit_nohz();
+ if (!current->pid)
+ rcu_exit_nohz();

/* Update jiffies first */
select_nohz_load_balancer(0);
@@ -550,7 +555,7 @@ void tick_nohz_restart_sched_tick(void)

tick_nohz_restart(ts, now);

- local_irq_enable();
+ local_irq_restore(flags);
}

static int tick_nohz_reprogram(struct tick_sched *ts, ktime_t now)
--
1.7.3.2

--
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/