From: Thomas Gleixner Date: Mon, 19 May 2025 08:33:30 +0000 (+0200) Subject: timekeeping: Provide ktime_get_ntp_seconds() X-Git-Tag: v6.17-rc1~155^2~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ffa0519baaed48ca953bd201e1b17f15dae21b2d;p=thirdparty%2Flinux.git 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 Link: https://lore.kernel.org/all/20250519083026.411809421@linutronix.de --- diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 19f4af1a37ea2..7d3693a72a011 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -2627,6 +2627,15 @@ int do_adjtimex(struct __kernel_timex *txc) return ret; } +/* + * Invoked from NTP with the time keeper lock held, so lockless access is + * fine. + */ +long ktime_get_ntp_seconds(unsigned int id) +{ + return timekeeper_data[id].timekeeper.xtime_sec; +} + #ifdef CONFIG_NTP_PPS /** * hardpps() - Accessor function to NTP __hardpps function diff --git a/kernel/time/timekeeping_internal.h b/kernel/time/timekeeping_internal.h index 8c9079108ffb2..973ede670a36e 100644 --- a/kernel/time/timekeeping_internal.h +++ b/kernel/time/timekeeping_internal.h @@ -45,4 +45,7 @@ static inline u64 clocksource_delta(u64 now, u64 last, u64 mask, u64 max_delta) unsigned long timekeeper_lock_irqsave(void); void timekeeper_unlock_irqrestore(unsigned long flags); +/* NTP specific interface to access the current seconds value */ +long ktime_get_ntp_seconds(unsigned int id); + #endif /* _TIMEKEEPING_INTERNAL_H */