Commit 0ff53d09 authored by Thomas Gleixner's avatar Thomas Gleixner

tick: sched: Force tick interrupt and get rid of softirq magic

We already got rid of the hrtimer reprogramming loops and hoops as
hrtimer now enforces an interrupt if the enqueued time is in the past.

Do the same for the nohz non highres mode. That gets rid of the need
to raise the softirq which only serves the purpose of getting the
machine out of the inner idle loop.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
Cc: Preeti U Murthy <preeti@linux.vnet.ibm.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Link: http://lkml.kernel.org/r/20150414203502.023464878@linutronix.deSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent afc08b15
...@@ -565,6 +565,20 @@ u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time) ...@@ -565,6 +565,20 @@ u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time)
} }
EXPORT_SYMBOL_GPL(get_cpu_iowait_time_us); EXPORT_SYMBOL_GPL(get_cpu_iowait_time_us);
static void tick_nohz_restart(struct tick_sched *ts, ktime_t now)
{
hrtimer_cancel(&ts->sched_timer);
hrtimer_set_expires(&ts->sched_timer, ts->last_tick);
/* Forward the time to expire in the future */
hrtimer_forward(&ts->sched_timer, now, tick_period);
if (ts->nohz_mode == NOHZ_MODE_HIGHRES)
hrtimer_start_expires(&ts->sched_timer, HRTIMER_MODE_ABS_PINNED);
else
tick_program_event(hrtimer_get_expires(&ts->sched_timer), 1);
}
static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts, static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts,
ktime_t now, int cpu) ktime_t now, int cpu)
{ {
...@@ -693,20 +707,16 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts, ...@@ -693,20 +707,16 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts,
goto out; goto out;
} }
if (ts->nohz_mode == NOHZ_MODE_HIGHRES) { if (ts->nohz_mode == NOHZ_MODE_HIGHRES)
hrtimer_start(&ts->sched_timer, expires, hrtimer_start(&ts->sched_timer, expires,
HRTIMER_MODE_ABS_PINNED); HRTIMER_MODE_ABS_PINNED);
goto out; else
} else if (!tick_program_event(expires, 0)) tick_program_event(expires, 1);
goto out; } else {
/* /* Tick is stopped, but required now. Enforce it */
* We are past the event already. So we crossed a tick_nohz_restart(ts, now);
* jiffie boundary. Update jiffies and raise the
* softirq.
*/
tick_do_update_jiffies64(ktime_get());
} }
raise_softirq_irqoff(TIMER_SOFTIRQ);
out: out:
ts->next_jiffies = next_jiffies; ts->next_jiffies = next_jiffies;
ts->last_jiffies = last_jiffies; ts->last_jiffies = last_jiffies;
...@@ -874,30 +884,6 @@ ktime_t tick_nohz_get_sleep_length(void) ...@@ -874,30 +884,6 @@ ktime_t tick_nohz_get_sleep_length(void)
return ts->sleep_length; return ts->sleep_length;
} }
static void tick_nohz_restart(struct tick_sched *ts, ktime_t now)
{
hrtimer_cancel(&ts->sched_timer);
hrtimer_set_expires(&ts->sched_timer, ts->last_tick);
while (1) {
/* Forward the time to expire in the future */
hrtimer_forward(&ts->sched_timer, now, tick_period);
if (ts->nohz_mode == NOHZ_MODE_HIGHRES) {
hrtimer_start_expires(&ts->sched_timer,
HRTIMER_MODE_ABS_PINNED);
break;
} else {
if (!tick_program_event(
hrtimer_get_expires(&ts->sched_timer), 0))
break;
}
/* Reread time and update jiffies */
now = ktime_get();
tick_do_update_jiffies64(now);
}
}
static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now) static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now)
{ {
/* Update jiffies first */ /* Update jiffies first */
...@@ -968,12 +954,6 @@ void tick_nohz_idle_exit(void) ...@@ -968,12 +954,6 @@ void tick_nohz_idle_exit(void)
local_irq_enable(); local_irq_enable();
} }
static int tick_nohz_reprogram(struct tick_sched *ts, ktime_t now)
{
hrtimer_forward(&ts->sched_timer, now, tick_period);
return tick_program_event(hrtimer_get_expires(&ts->sched_timer), 0);
}
/* /*
* The nohz low res interrupt handler * The nohz low res interrupt handler
*/ */
...@@ -992,10 +972,8 @@ static void tick_nohz_handler(struct clock_event_device *dev) ...@@ -992,10 +972,8 @@ static void tick_nohz_handler(struct clock_event_device *dev)
if (unlikely(ts->tick_stopped)) if (unlikely(ts->tick_stopped))
return; return;
while (tick_nohz_reprogram(ts, now)) { hrtimer_forward(&ts->sched_timer, now, tick_period);
now = ktime_get(); tick_program_event(hrtimer_get_expires(&ts->sched_timer), 1);
tick_do_update_jiffies64(now);
}
} }
/** /**
...@@ -1025,12 +1003,9 @@ static void tick_nohz_switch_to_nohz(void) ...@@ -1025,12 +1003,9 @@ static void tick_nohz_switch_to_nohz(void)
/* Get the next period */ /* Get the next period */
next = tick_init_jiffy_update(); next = tick_init_jiffy_update();
for (;;) { hrtimer_forward_now(&ts->sched_timer, tick_period);
hrtimer_set_expires(&ts->sched_timer, next); hrtimer_set_expires(&ts->sched_timer, next);
if (!tick_program_event(next, 0)) tick_program_event(next, 1);
break;
next = ktime_add(next, tick_period);
}
local_irq_enable(); local_irq_enable();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment