Skip to content

Commit

Permalink
vdso/gettimeofday: Prepare helper functions for introduction of struc…
Browse files Browse the repository at this point in the history
…t vdso_clock

To support multiple PTP clocks, the VDSO data structure needs to be
reworked. All clock specific data will end up in struct vdso_clock and in
struct vdso_time_data there will be array of VDSO clocks. At the moment,
vdso_clock is simply a define which maps vdso_clock to vdso_time_data.

To prepare for the rework of the data structures, replace the struct
vdso_time_data pointer argument of the helper functions with struct
vdso_clock pointer where applicable.

No functional change.

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Nam Cao <namcao@linutronix.de>
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250303-vdso-clock-v1-11-c1b5c69a166f@linutronix.de
  • Loading branch information
Anna-Maria Behnsen authored and Thomas Gleixner committed Mar 8, 2025
1 parent 8c3f5cb commit 8080197
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/vdso/gettimeofday.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
#endif

#ifdef CONFIG_GENERIC_VDSO_OVERFLOW_PROTECT
static __always_inline bool vdso_delta_ok(const struct vdso_time_data *vd, u64 delta)
static __always_inline bool vdso_delta_ok(const struct vdso_clock *vc, u64 delta)
{
return delta < vd->max_cycles;
return delta < vc->max_cycles;
}
#else
static __always_inline bool vdso_delta_ok(const struct vdso_time_data *vd, u64 delta)
static __always_inline bool vdso_delta_ok(const struct vdso_clock *vc, u64 delta)
{
return true;
}
Expand All @@ -39,14 +39,14 @@ static __always_inline u64 vdso_shift_ns(u64 ns, u32 shift)
* Default implementation which works for all sane clocksources. That
* obviously excludes x86/TSC.
*/
static __always_inline u64 vdso_calc_ns(const struct vdso_time_data *vd, u64 cycles, u64 base)
static __always_inline u64 vdso_calc_ns(const struct vdso_clock *vc, u64 cycles, u64 base)
{
u64 delta = (cycles - vd->cycle_last) & VDSO_DELTA_MASK(vd);
u64 delta = (cycles - vc->cycle_last) & VDSO_DELTA_MASK(vc);

if (likely(vdso_delta_ok(vd, delta)))
return vdso_shift_ns((delta * vd->mult) + base, vd->shift);
if (likely(vdso_delta_ok(vc, delta)))
return vdso_shift_ns((delta * vc->mult) + base, vc->shift);

return mul_u64_u32_add_u64_shr(delta, vd->mult, base, vd->shift);
return mul_u64_u32_add_u64_shr(delta, vc->mult, base, vc->shift);
}
#endif /* vdso_calc_ns */

Expand All @@ -58,9 +58,9 @@ static inline bool __arch_vdso_hres_capable(void)
#endif

#ifndef vdso_clocksource_ok
static inline bool vdso_clocksource_ok(const struct vdso_time_data *vd)
static inline bool vdso_clocksource_ok(const struct vdso_clock *vc)
{
return vd->clock_mode != VDSO_CLOCKMODE_NONE;
return vc->clock_mode != VDSO_CLOCKMODE_NONE;
}
#endif

Expand Down

0 comments on commit 8080197

Please sign in to comment.