Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vdso: Introduce aux_clock_resolution_ns()

Move the constant resolution to a shared header,
so the vDSO can use it and return it without going through a syscall.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250701-vdso-auxclock-v1-10-df7d9f87b9b8@linutronix.de

authored by

Thomas Weißschuh and committed by
Thomas Gleixner
9b7fc3f1 562f03ed

+17 -2
+13
include/vdso/auxclock.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _VDSO_AUXCLOCK_H 3 + #define _VDSO_AUXCLOCK_H 4 + 5 + #include <uapi/linux/time.h> 6 + #include <uapi/linux/types.h> 7 + 8 + static __always_inline u64 aux_clock_resolution_ns(void) 9 + { 10 + return 1; 11 + } 12 + 13 + #endif /* _VDSO_AUXCLOCK_H */
+4 -2
kernel/time/timekeeping.c
··· 26 26 #include <linux/audit.h> 27 27 #include <linux/random.h> 28 28 29 + #include <vdso/auxclock.h> 30 + 29 31 #include "tick-internal.h" 30 32 #include "ntp_internal.h" 31 33 #include "timekeeping_internal.h" ··· 2878 2876 if (!clockid_aux_valid(id)) 2879 2877 return -ENODEV; 2880 2878 2881 - tp->tv_sec = 0; 2882 - tp->tv_nsec = 1; 2879 + tp->tv_sec = aux_clock_resolution_ns() / NSEC_PER_SEC; 2880 + tp->tv_nsec = aux_clock_resolution_ns() % NSEC_PER_SEC; 2883 2881 return 0; 2884 2882 } 2885 2883