timekeeping: Provide ktime_get_clock_ts64()
authorThomas Gleixner <tglx@linutronix.de>
Tue, 1 Jul 2025 13:26:58 +0000 (15:26 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 3 Jul 2025 12:18:06 +0000 (14:18 +0200)
commit5b605dbee07dda8fd538af1f07cbf1baf0a49cbc
tree6b85d5c42945b6d206898c656c70e192697d3e2d
parent19272b37aa4f83ca52bdf9c16d5d81bdd1354494
timekeeping: Provide ktime_get_clock_ts64()

PTP implements an inline switch case for taking timestamps from various
POSIX clock IDs, which already consumes quite some text space. Expanding it
for auxiliary clocks really becomes too big for inlining.

Provide a out of line version.

The function invalidates the timestamp in case the clock is invalid. The
invalidation allows to implement a validation check without the need to
propagate a return value through deep existing call chains.

Due to merge logistics this temporarily defines CLOCK_AUX[_LAST] if
undefined, so that the plain branch, which does not contain any of the core
timekeeper changes, can be pulled into the networking tree as prerequisite
for the PTP side changes. These temporary defines are removed after that
branch is merged into the tip::timers/ptp branch. That way the result in
-next or upstream in the next merge window has zero dependencies.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Acked-by: John Stultz <jstultz@google.com>
Link: https://lore.kernel.org/all/20250701132628.357686408@linutronix.de
include/linux/timekeeping.h
kernel/time/timekeeping.c