tick-sched: recalculate sleep length each time it is requested

Recalculating the sleep length each time its called allows us to account
for the fact that the amount of time we can sleep for might change after
tick_nohz_stop_sched_tick is called in idle. The prime example of this
is an idle notifier that cancels timers as we are entering idle.

Change-Id: I92871efc7befb3fee2a816da16145ba9da334a9e
Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>
(cherry picked from commit 9feb87d70208e2236d24ef0ac2fa4d0e28e7d335)
This commit is contained in:
Jeff Ohlstein 2012-07-17 16:45:19 -07:00 committed by Rohit Vaswani
parent b551c512c1
commit 1c0a4128e4
2 changed files with 2 additions and 5 deletions

View file

@ -44,7 +44,6 @@ enum tick_nohz_mode {
* @idle_exittime: Time when the idle state was left
* @idle_sleeptime: Sum of the time slept in idle with sched tick stopped
* @iowait_sleeptime: Sum of the time slept in idle with sched tick stopped, with IO outstanding
* @sleep_length: Duration of the current idle sleep
* @do_timer_lst: CPU was the last one doing do_timer before going idle
*/
struct tick_sched {
@ -63,7 +62,6 @@ struct tick_sched {
ktime_t idle_exittime;
ktime_t idle_sleeptime;
ktime_t iowait_sleeptime;
ktime_t sleep_length;
unsigned long last_jiffies;
unsigned long next_jiffies;
ktime_t idle_expires;

View file

@ -447,7 +447,6 @@ static void tick_nohz_stop_sched_tick(struct tick_sched *ts)
out:
ts->next_jiffies = next_jiffies;
ts->last_jiffies = last_jiffies;
ts->sleep_length = ktime_sub(dev->next_event, now);
}
/**
@ -516,8 +515,8 @@ void tick_nohz_irq_exit(void)
ktime_t tick_nohz_get_sleep_length(void)
{
struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
return ts->sleep_length;
struct clock_event_device *dev = __get_cpu_var(tick_cpu_device).evtdev;
return ktime_sub(dev->next_event, ts->idle_entrytime);
}
static void tick_nohz_restart(struct tick_sched *ts, ktime_t now)