Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 36cd28a4cdd0 ("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

authored by

Anna-Maria Behnsen and committed by
Thomas Gleixner
8a2c9c7e b5e6f598

+7 -4
+7 -4
kernel/time/timer.c
··· 944 944 unsigned long jnow = READ_ONCE(jiffies); 945 945 946 946 /* 947 - * No need to forward if we are close enough below jiffies. 948 - * Also while executing timers, base->clk is 1 offset ahead 949 - * of jiffies to avoid endless requeuing to current jiffies. 947 + * Check whether we can forward the base. We can only do that when 948 + * @basej is past base->clk otherwise we might rewind base->clk. 950 949 */ 951 - if ((long)(jnow - base->clk) < 1) 950 + if (time_before_eq(jnow, base->clk)) 952 951 return; 953 952 954 953 /* ··· 2020 2021 */ 2021 2022 WARN_ON_ONCE(!levels && !base->next_expiry_recalc 2022 2023 && base->timers_pending); 2024 + /* 2025 + * While executing timers, base->clk is set 1 offset ahead of 2026 + * jiffies to avoid endless requeuing to current jiffies. 2027 + */ 2023 2028 base->clk++; 2024 2029 next_expiry_recalc(base); 2025 2030