[patch V2 25/26] timekeeping: Provide update for auxiliary timekeepers
From: Thomas Gleixner <hidden>
Date: 2025-05-19 08:33:46
Also in:
lkml
Update the auxiliary timekeepers periodically. For now this is tied to the system timekeeper update from the tick. This might be revisited and moved out of the tick. Signed-off-by: Thomas Gleixner <redacted> --- kernel/time/timekeeping.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) ---
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c@@ -131,9 +131,11 @@ static struct tk_fast tk_fast_raw ____c #ifdef CONFIG_POSIX_AUX_CLOCKS static __init void tk_aux_setup(void); static void tk_aux_update_clocksource(void); +static void tk_aux_advance(void); #else static inline void tk_aux_setup(void) { } static inline void tk_aux_update_clocksource(void) { } +static inline void tk_aux_advance(void) { } #endif unsigned long timekeeper_lock_irqsave(void)
@@ -2312,11 +2314,13 @@ static bool timekeeping_advance(enum tim /** * update_wall_time - Uses the current clocksource to increment the wall time * + * It also updates the enabled auxiliary clock timekeepers */ void update_wall_time(void) { if (timekeeping_advance(TK_ADV_TICK)) clock_was_set_delayed(); + tk_aux_advance(); } /**
@@ -2762,6 +2766,20 @@ static void tk_aux_update_clocksource(vo } } +static void tk_aux_advance(void) +{ + unsigned long active = READ_ONCE(aux_timekeepers); + unsigned int id; + + for_each_set_bit(id, &active, BITS_PER_LONG) { + struct tk_data *tkd = &timekeeper_data[id + TIMEKEEPER_AUX]; + + guard(raw_spinlock)(&tkd->lock); + if (tkd->shadow_timekeeper.clock_valid) + __timekeeping_advance(tkd, TK_ADV_TICK); + } +} + /** * ktime_get_aux - Get TAI time for a AUX clock * @id: ID of the clock to read (CLOCK_AUX...)