Skip to content

Commit b560f85

Browse files
committed
timers: Clarify check in forward_timer_base()
JIRA: https://issues.redhat.com/browse/RHEL-33787 commit 8a2c9c7 Author: Anna-Maria Behnsen <anna-maria@linutronix.de> Date: Fri Dec 1 10:26:30 2023 +0100 timers: Clarify check in forward_timer_base() The current check whether a forward of the timer base is required can be simplified by using an already existing comparison function which is easier to read. The related comment is outdated and was not updated when the check changed in commit 36cd28a ("timers: Lower base clock forwarding threshold"). Use time_before_eq() for the check and replace the comment by copying the comment from the same check inside get_next_timer_interrupt(). Move the precious information of the outdated comment to the proper place in __run_timers(). No functional change. 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-9-anna-maria@linutronix.de Signed-off-by: Phil Auld <pauld@redhat.com>
1 parent 6500c07 commit b560f85

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
@@ -891,11 +891,10 @@ static inline void forward_timer_base(struct timer_base *base)
891891
unsigned long jnow = READ_ONCE(jiffies);
892892

893893
/*
894-
* No need to forward if we are close enough below jiffies.
895-
* Also while executing timers, base->clk is 1 offset ahead
896-
* of jiffies to avoid endless requeuing to current jiffies.
894+
* Check whether we can forward the base. We can only do that when
895+
* @basej is past base->clk otherwise we might rewind base->clk.
897896
*/
898-
if ((long)(jnow - base->clk) < 1)
897+
if (time_before_eq(jnow, base->clk))
899898
return;
900899

901900
/*
@@ -1968,6 +1967,10 @@ static inline void __run_timers(struct timer_base *base)
19681967
*/
19691968
WARN_ON_ONCE(!levels && !base->next_expiry_recalc
19701969
&& base->timers_pending);
1970+
/*
1971+
* While executing timers, base->clk is set 1 offset ahead of
1972+
* jiffies to avoid endless requeuing to current jiffies.
1973+
*/
19711974
base->clk++;
19721975
next_expiry_recalc(base);
19731976

0 commit comments

Comments
 (0)