Skip to content

Commit 1e49048

Browse files
anna-marialxKAGA-KOKO
authored andcommitted
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 <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Frederic Weisbecker <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 8a2c9c7 commit 1e49048

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
@@ -939,30 +939,34 @@ get_target_base(struct timer_base *base, unsigned tflags)
939939
return get_timer_this_cpu_base(tflags);
940940
}
941941

942-
static inline void forward_timer_base(struct timer_base *base)
942+
static inline void __forward_timer_base(struct timer_base *base,
943+
unsigned long basej)
943944
{
944-
unsigned long jnow = READ_ONCE(jiffies);
945-
946945
/*
947946
* Check whether we can forward the base. We can only do that when
948947
* @basej is past base->clk otherwise we might rewind base->clk.
949948
*/
950-
if (time_before_eq(jnow, base->clk))
949+
if (time_before_eq(basej, base->clk))
951950
return;
952951

953952
/*
954953
* If the next expiry value is > jiffies, then we fast forward to
955954
* jiffies otherwise we forward to the next expiry value.
956955
*/
957-
if (time_after(base->next_expiry, jnow)) {
958-
base->clk = jnow;
956+
if (time_after(base->next_expiry, basej)) {
957+
base->clk = basej;
959958
} else {
960959
if (WARN_ON_ONCE(time_before(base->next_expiry, base->clk)))
961960
return;
962961
base->clk = base->next_expiry;
963962
}
963+
964964
}
965965

966+
static inline void forward_timer_base(struct timer_base *base)
967+
{
968+
__forward_timer_base(base, READ_ONCE(jiffies));
969+
}
966970

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

0 commit comments

Comments
 (0)