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

Configure Feed

Select the types of activity you want to include in your feed.

vdso/vsyscall: Introduce a helper to fill clock configurations

The logic to configure a 'struct vdso_clock' from a
'struct tk_read_base' is copied two times.
Split it into a shared function to reduce the duplication,
especially as another user will be added for auxiliary clocks.

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-2-df7d9f87b9b8@linutronix.de

authored by

Thomas Weißschuh and committed by
Thomas Gleixner
6fedaf68 068f7b64

+13 -14
+13 -14
kernel/time/vsyscall.c
··· 15 15 16 16 #include "timekeeping_internal.h" 17 17 18 + static inline void fill_clock_configuration(struct vdso_clock *vc, const struct tk_read_base *base) 19 + { 20 + vc->cycle_last = base->cycle_last; 21 + #ifdef CONFIG_GENERIC_VDSO_OVERFLOW_PROTECT 22 + vc->max_cycles = base->clock->max_cycles; 23 + #endif 24 + vc->mask = base->mask; 25 + vc->mult = base->mult; 26 + vc->shift = base->shift; 27 + } 28 + 18 29 static inline void update_vdso_time_data(struct vdso_time_data *vdata, struct timekeeper *tk) 19 30 { 20 31 struct vdso_clock *vc = vdata->clock_data; 21 32 struct vdso_timestamp *vdso_ts; 22 33 u64 nsec, sec; 23 34 24 - vc[CS_HRES_COARSE].cycle_last = tk->tkr_mono.cycle_last; 25 - #ifdef CONFIG_GENERIC_VDSO_OVERFLOW_PROTECT 26 - vc[CS_HRES_COARSE].max_cycles = tk->tkr_mono.clock->max_cycles; 27 - #endif 28 - vc[CS_HRES_COARSE].mask = tk->tkr_mono.mask; 29 - vc[CS_HRES_COARSE].mult = tk->tkr_mono.mult; 30 - vc[CS_HRES_COARSE].shift = tk->tkr_mono.shift; 31 - vc[CS_RAW].cycle_last = tk->tkr_raw.cycle_last; 32 - #ifdef CONFIG_GENERIC_VDSO_OVERFLOW_PROTECT 33 - vc[CS_RAW].max_cycles = tk->tkr_raw.clock->max_cycles; 34 - #endif 35 - vc[CS_RAW].mask = tk->tkr_raw.mask; 36 - vc[CS_RAW].mult = tk->tkr_raw.mult; 37 - vc[CS_RAW].shift = tk->tkr_raw.shift; 35 + fill_clock_configuration(&vc[CS_HRES_COARSE], &tk->tkr_mono); 36 + fill_clock_configuration(&vc[CS_RAW], &tk->tkr_raw); 38 37 39 38 /* CLOCK_MONOTONIC */ 40 39 vdso_ts = &vc[CS_HRES_COARSE].basetime[CLOCK_MONOTONIC];