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: 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

authored by

Anna-Maria Behnsen and committed by
Thomas Gleixner
1e490484 8a2c9c7e

+10 -6
+10 -6
kernel/time/timer.c
··· 939 939 return get_timer_this_cpu_base(tflags); 940 940 } 941 941 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) 943 944 { 944 - unsigned long jnow = READ_ONCE(jiffies); 945 - 946 945 /* 947 946 * Check whether we can forward the base. We can only do that when 948 947 * @basej is past base->clk otherwise we might rewind base->clk. 949 948 */ 950 - if (time_before_eq(jnow, base->clk)) 949 + if (time_before_eq(basej, base->clk)) 951 950 return; 952 951 953 952 /* 954 953 * If the next expiry value is > jiffies, then we fast forward to 955 954 * jiffies otherwise we forward to the next expiry value. 956 955 */ 957 - if (time_after(base->next_expiry, jnow)) { 958 - base->clk = jnow; 956 + if (time_after(base->next_expiry, basej)) { 957 + base->clk = basej; 959 958 } else { 960 959 if (WARN_ON_ONCE(time_before(base->next_expiry, base->clk))) 961 960 return; 962 961 base->clk = base->next_expiry; 963 962 } 963 + 964 964 } 965 965 966 + static inline void forward_timer_base(struct timer_base *base) 967 + { 968 + __forward_timer_base(base, READ_ONCE(jiffies)); 969 + } 966 970 967 971 /* 968 972 * We are using hashed locking: Holding per_cpu(timer_bases[x]).lock means