Skip to content

Commit 3f6a1a1

Browse files
committed
timers: Split out forward timer base functionality
JIRA: https://issues.redhat.com/browse/RHEL-33787 commit 1e49048 Author: Anna-Maria Behnsen <anna-maria@linutronix.de> Date: Fri Dec 1 10:26:31 2023 +0100 timers: Split out forward timer base functionality Forwarding timer base is done when the next expiry value is calculated and when a new timer is enqueued. When the next expiry value is calculated the jiffies value is already available and does not need to be reread a second time. Splitting out the forward timer base functionality to make it executable via both contextes - those where jiffies are already known and those, where jiffies need to be read. 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-10-anna-maria@linutronix.de Signed-off-by: Phil Auld <pauld@redhat.com>
1 parent b560f85 commit 3f6a1a1

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

kernel/time/timer.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -886,30 +886,34 @@ get_target_base(struct timer_base *base, unsigned tflags)
886886
return get_timer_this_cpu_base(tflags);
887887
}
888888

889-
static inline void forward_timer_base(struct timer_base *base)
889+
static inline void __forward_timer_base(struct timer_base *base,
890+
unsigned long basej)
890891
{
891-
unsigned long jnow = READ_ONCE(jiffies);
892-
893892
/*
894893
* Check whether we can forward the base. We can only do that when
895894
* @basej is past base->clk otherwise we might rewind base->clk.
896895
*/
897-
if (time_before_eq(jnow, base->clk))
896+
if (time_before_eq(basej, base->clk))
898897
return;
899898

900899
/*
901900
* If the next expiry value is > jiffies, then we fast forward to
902901
* jiffies otherwise we forward to the next expiry value.
903902
*/
904-
if (time_after(base->next_expiry, jnow)) {
905-
base->clk = jnow;
903+
if (time_after(base->next_expiry, basej)) {
904+
base->clk = basej;
906905
} else {
907906
if (WARN_ON_ONCE(time_before(base->next_expiry, base->clk)))
908907
return;
909908
base->clk = base->next_expiry;
910909
}
910+
911911
}
912912

913+
static inline void forward_timer_base(struct timer_base *base)
914+
{
915+
__forward_timer_base(base, READ_ONCE(jiffies));
916+
}
913917

914918
/*
915919
* We are using hashed locking: Holding per_cpu(timer_bases[x]).lock means

0 commit comments

Comments
 (0)