Skip to content

Commit cbf04a2

Browse files
anna-marialxKAGA-KOKO
authored andcommitted
tick-sched: Warn when next tick seems to be in the past
When the next tick is in the past, the delta between basemono and the next tick gets negativ. But the next tick should never be in the past. The negative effect of a wrong next tick might be a stop of the tick and timers might expire late. To prevent expensive debugging when changing underlying code, add a WARN_ON_ONCE into this code path. To prevent complete misbehaviour, also reset next_tick to basemono in this case. Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Frederic Weisbecker <frederic@kernel.org> Link: https://lore.kernel.org/r/20231201092654.34614-4-anna-maria@linutronix.de
1 parent 3180506 commit cbf04a2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

kernel/time/tick-sched.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,10 @@ static ktime_t tick_nohz_next_event(struct tick_sched *ts, int cpu)
839839
ts->next_timer = next_tick;
840840
}
841841

842+
/* Make sure next_tick is never before basemono! */
843+
if (WARN_ON_ONCE(basemono > next_tick))
844+
next_tick = basemono;
845+
842846
/*
843847
* If the tick is due in the next period, keep it ticking or
844848
* force prod the timer.

0 commit comments

Comments
 (0)