Skip to content

Commit 62c1256

Browse files
npigginKAGA-KOKO
authored andcommitted
timers/nohz: Switch to ONESHOT_STOPPED in the low-res handler when the tick is stopped
When tick_nohz_stop_tick() stops the tick and high resolution timers are disabled, then the clock event device is not put into ONESHOT_STOPPED mode. This can lead to spurious timer interrupts with some clock event device drivers that don't shut down entirely after firing. Eliminate these by putting the device into ONESHOT_STOPPED mode at points where it is not being reprogrammed. When there are no timers active, then tick_program_event() with KTIME_MAX can be used to stop the device. When there is a timer active, the device can be stopped at the next tick (any new timer added by timers will reprogram the tick). Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ce8abf3 commit 62c1256

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

kernel/time/tick-sched.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,8 @@ static void tick_nohz_stop_tick(struct tick_sched *ts, int cpu)
928928
if (unlikely(expires == KTIME_MAX)) {
929929
if (ts->nohz_mode == NOHZ_MODE_HIGHRES)
930930
hrtimer_cancel(&ts->sched_timer);
931+
else
932+
tick_program_event(KTIME_MAX, 1);
931933
return;
932934
}
933935

@@ -1364,9 +1366,15 @@ static void tick_nohz_handler(struct clock_event_device *dev)
13641366
tick_sched_do_timer(ts, now);
13651367
tick_sched_handle(ts, regs);
13661368

1367-
/* No need to reprogram if we are running tickless */
1368-
if (unlikely(ts->tick_stopped))
1369+
if (unlikely(ts->tick_stopped)) {
1370+
/*
1371+
* The clockevent device is not reprogrammed, so change the
1372+
* clock event device to ONESHOT_STOPPED to avoid spurious
1373+
* interrupts on devices which might not be truly one shot.
1374+
*/
1375+
tick_program_event(KTIME_MAX, 1);
13691376
return;
1377+
}
13701378

13711379
hrtimer_forward(&ts->sched_timer, now, TICK_NSEC);
13721380
tick_program_event(hrtimer_get_expires(&ts->sched_timer), 1);

0 commit comments

Comments
 (0)