[patch V2 09/26] timekeeping: Make __timekeeping_advance() reusable
From: Thomas Gleixner
Date: Mon May 19 2025 - 04:36:57 EST
From: Anna-Maria Behnsen <anna-maria@xxxxxxxxxxxxx>
In __timekeeping_advance() the pointer to struct tk_data is hardcoded by the
use of &tk_core. As long as there is only a single timekeeper (tk_core),
this is not a problem. But when __timekeeping_advance() will be reused for
per auxiliary timekeepers, __timekeeping_advance() needs to be generalized.
Add a pointer to struct tk_data as function argument of
__timekeeping_advance() and adapt all call sites.
Signed-off-by: Anna-Maria Behnsen <anna-maria@xxxxxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
---
kernel/time/timekeeping.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
---
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -2196,10 +2196,10 @@ static u64 logarithmic_accumulation(stru
* timekeeping_advance - Updates the timekeeper to the current time and
* current NTP tick length
*/
-static bool __timekeeping_advance(enum timekeeping_adv_mode mode)
+static bool __timekeeping_advance(struct tk_data *tkd, enum timekeeping_adv_mode mode)
{
- struct timekeeper *tk = &tk_core.shadow_timekeeper;
- struct timekeeper *real_tk = &tk_core.timekeeper;
+ struct timekeeper *tk = &tkd->shadow_timekeeper;
+ struct timekeeper *real_tk = &tkd->timekeeper;
unsigned int clock_set = 0;
int shift = 0, maxshift;
u64 offset, orig_offset;
@@ -2252,7 +2252,7 @@ static bool __timekeeping_advance(enum t
if (orig_offset != offset)
tk_update_coarse_nsecs(tk);
- timekeeping_update_from_shadow(&tk_core, clock_set);
+ timekeeping_update_from_shadow(tkd, clock_set);
return !!clock_set;
}
@@ -2260,7 +2260,7 @@ static bool __timekeeping_advance(enum t
static bool timekeeping_advance(enum timekeeping_adv_mode mode)
{
guard(raw_spinlock_irqsave)(&tk_core.lock);
- return __timekeeping_advance(mode);
+ return __timekeeping_advance(&tk_core, mode);
}
/**
@@ -2598,7 +2598,7 @@ int do_adjtimex(struct __kernel_timex *t
/* Update the multiplier immediately if frequency was set directly */
if (txc->modes & (ADJ_FREQUENCY | ADJ_TICK))
- clock_set |= __timekeeping_advance(TK_ADV_FREQ);
+ clock_set |= __timekeeping_advance(&tk_core, TK_ADV_FREQ);
}
if (txc->modes & ADJ_SETOFFSET)