]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
timekeeping: Provide ktime_get_ntp_seconds()
authorThomas Gleixner <tglx@linutronix.de>
Mon, 19 May 2025 08:33:30 +0000 (10:33 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 19 Jun 2025 12:28:23 +0000 (14:28 +0200)
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
kernel/time/timekeeping.c
kernel/time/timekeeping_internal.h

index 19f4af1a37ea25e4c9539654ecafec3ff0ca3503..7d3693a72a01120501e9061d5a110bd508d2f83c 100644 (file)
@@ -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
index 8c9079108ffb23444486db2dbda3f5d042cf929c..973ede670a36edfe74546fcad9eefb75597103e9 100644 (file)
@@ -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 */