[PATCH v2 5/6] pps: Always use ktime_get_snapshot_id() for pps_get_ts()
From: David Woodhouse
Date: Thu Nov 05 2026 - 22:13:37 EST
From: David Woodhouse <dwmw@xxxxxxxxxxxx>
Without CONFIG_NTP_PPS, pps_get_ts() fills in ts_real with
ktime_get_real_ts64(). Use ktime_get_snapshot_id() unconditionally so
that PPS timestamps always come from the snapshot machinery; only the
raw timestamp remains conditional on CONFIG_NTP_PPS.
This is preparation for the next commit, which corrects the snapshot's
::systime for the accumulated ntp_error. That correction should reach
*all* PPS consumers, not only those on CONFIG_NTP_PPS kernels.
The cost of the snapshot on a small ARM board (Cortex-A53, 12.5MHz
arch counter) is 38.8ns from the pulse handler to the counter read,
against 23.4ns for ktime_get_real_ts64() — both small against the
~2.8µs measured from the pin edge to the handler.
Signed-off-by: David Woodhouse <dwmw@xxxxxxxxxxxx>
---
v2: New in this series, ahead of the snapshot correction so that its
effect explicitly covers all PPS consumers.
include/linux/pps_kernel.h | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/include/linux/pps_kernel.h b/include/linux/pps_kernel.h
index 00b840970d56..35d6ac06a0c0 100644
--- a/include/linux/pps_kernel.h
+++ b/include/linux/pps_kernel.h
@@ -100,14 +100,12 @@ static inline void timespec_to_pps_ktime(struct pps_ktime *kt,
static inline void pps_get_ts(struct pps_event_time *ts)
{
-#ifdef CONFIG_NTP_PPS
struct system_time_snapshot snap;
ktime_get_snapshot_id(CLOCK_REALTIME, &snap);
ts->ts_real = ktime_to_timespec64(snap.systime);
+#ifdef CONFIG_NTP_PPS
ts->ts_raw = ktime_to_timespec64(snap.monoraw);
-#else
- ktime_get_real_ts64(&ts->ts_real);
#endif
}
--
2.43.0