Skip to content

Commit ffa0519

Browse files
committed
timekeeping: Provide ktime_get_ntp_seconds()
ntp_adjtimex() requires access to the actual time keeper per timekeeper ID. Provide an interface. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/all/20250519083026.411809421@linutronix.de
1 parent 22c62b9 commit ffa0519

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

kernel/time/timekeeping.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2627,6 +2627,15 @@ int do_adjtimex(struct __kernel_timex *txc)
26272627
return ret;
26282628
}
26292629

2630+
/*
2631+
* Invoked from NTP with the time keeper lock held, so lockless access is
2632+
* fine.
2633+
*/
2634+
long ktime_get_ntp_seconds(unsigned int id)
2635+
{
2636+
return timekeeper_data[id].timekeeper.xtime_sec;
2637+
}
2638+
26302639
#ifdef CONFIG_NTP_PPS
26312640
/**
26322641
* hardpps() - Accessor function to NTP __hardpps function

kernel/time/timekeeping_internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,7 @@ static inline u64 clocksource_delta(u64 now, u64 last, u64 mask, u64 max_delta)
4545
unsigned long timekeeper_lock_irqsave(void);
4646
void timekeeper_unlock_irqrestore(unsigned long flags);
4747

48+
/* NTP specific interface to access the current seconds value */
49+
long ktime_get_ntp_seconds(unsigned int id);
50+
4851
#endif /* _TIMEKEEPING_INTERNAL_H */

0 commit comments

Comments
 (0)