Skip to content

Commit c54bc0f

Browse files
anna-marialxKAGA-KOKO
authored andcommitted
timers: Fix warning condition in __run_timers()
When the timer base is empty, base::next_expiry is set to base::clk + NEXT_TIMER_MAX_DELTA and base::next_expiry_recalc is false. When no timer is queued until jiffies reaches base::next_expiry value, the warning for not finding any expired timer and base::next_expiry_recalc is false in __run_timers() triggers. To prevent triggering the warning in this valid scenario base::timers_pending needs to be added to the warning condition. Fixes: 31cd0e1 ("timers: Recalculate next timer interrupt only when necessary") Reported-by: Johannes Berg <johannes@sipsolutions.net> 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/20220405191732.7438-3-anna-maria@linutronix.de
1 parent 3123109 commit c54bc0f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

kernel/time/timer.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,11 +1722,14 @@ static inline void __run_timers(struct timer_base *base)
17221722
time_after_eq(jiffies, base->next_expiry)) {
17231723
levels = collect_expired_timers(base, heads);
17241724
/*
1725-
* The only possible reason for not finding any expired
1726-
* timer at this clk is that all matching timers have been
1727-
* dequeued.
1725+
* The two possible reasons for not finding any expired
1726+
* timer at this clk are that all matching timers have been
1727+
* dequeued or no timer has been queued since
1728+
* base::next_expiry was set to base::clk +
1729+
* NEXT_TIMER_MAX_DELTA.
17281730
*/
1729-
WARN_ON_ONCE(!levels && !base->next_expiry_recalc);
1731+
WARN_ON_ONCE(!levels && !base->next_expiry_recalc
1732+
&& base->timers_pending);
17301733
base->clk++;
17311734
base->next_expiry = __next_timer_interrupt(base);
17321735

0 commit comments

Comments
 (0)