Re: [PATCH v12 09/13] arm, tile: turn off timer tick for oneshot_stopped state

From: Daniel Lezcano
Date: Thu Apr 07 2016 - 12:58:45 EST


On Tue, Apr 05, 2016 at 01:38:38PM -0400, Chris Metcalf wrote:
> When the schedule tick is disabled in tick_nohz_stop_sched_tick(),
> we call hrtimer_cancel(), which eventually calls down into
> __remove_hrtimer() and thus into hrtimer_force_reprogram().
> That function's call to tick_program_event() detects that
> we are trying to set the expiration to KTIME_MAX and calls
> clockevents_switch_state() to set the state to ONESHOT_STOPPED,
> and returns. See commit 8fff52fd5093 ("clockevents: Introduce
> CLOCK_EVT_STATE_ONESHOT_STOPPED state") for more background.
>
> However, by default the internal __clockevents_switch_state() code
> doesn't have a "set_state_oneshot_stopped" function pointer for
> the arm_arch_timer or tile clock_event_device structures, so that
> code returns -ENOSYS, and we end up not setting the state, and more
> importantly, we don't actually turn off the hardware timer.
> As a result, the timer tick we were waiting for before is still
> queued, and fires shortly afterwards, only to discover there was
> nothing for it to do, at which point it quiesces.
>
> The fix is to provide that function pointer field, and like the
> other function pointers, have it just turn off the timer interrupt.
> Any call to set a new timer interval will properly re-enable it.
>
> This fix avoids a small performance hiccup for regular applications,
> but for TASK_ISOLATION code, it fixes a potentially serious
> kernel timer interruption to the time-sensitive application.
>
> Signed-off-by: Chris Metcalf <cmetcalf@xxxxxxxxxxxx>
> ---

Acked-by: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>