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: Consolidate vdso_calc_delta()

Consolidate vdso_calc_delta(), in preparation for further simplification.

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20240325064023.2997-2-adrian.hunter@intel.com

authored by

Adrian Hunter and committed by
Thomas Gleixner
c8e3a8b6 82ccdf06

+21 -21
+11 -15
arch/powerpc/include/asm/vdso/gettimeofday.h
··· 13 13 14 14 #define VDSO_HAS_TIME 1 15 15 16 + /* 17 + * powerpc specific delta calculation. 18 + * 19 + * This variant removes the masking of the subtraction because the 20 + * clocksource mask of all VDSO capable clocksources on powerpc is U64_MAX 21 + * which would result in a pointless operation. The compiler cannot 22 + * optimize it away as the mask comes from the vdso data and is not compile 23 + * time constant. 24 + */ 25 + #define VDSO_DELTA_NOMASK 1 26 + 16 27 static __always_inline int do_syscall_2(const unsigned long _r0, const unsigned long _r3, 17 28 const unsigned long _r4) 18 29 { ··· 114 103 return true; 115 104 } 116 105 #define vdso_clocksource_ok vdso_clocksource_ok 117 - 118 - /* 119 - * powerpc specific delta calculation. 120 - * 121 - * This variant removes the masking of the subtraction because the 122 - * clocksource mask of all VDSO capable clocksources on powerpc is U64_MAX 123 - * which would result in a pointless operation. The compiler cannot 124 - * optimize it away as the mask comes from the vdso data and is not compile 125 - * time constant. 126 - */ 127 - static __always_inline u64 vdso_calc_delta(u64 cycles, u64 last, u64 mask, u32 mult) 128 - { 129 - return (cycles - last) * mult; 130 - } 131 - #define vdso_calc_delta vdso_calc_delta 132 106 133 107 #ifndef __powerpc64__ 134 108 static __always_inline u64 vdso_shift_ns(u64 ns, unsigned long shift)
+2 -5
arch/s390/include/asm/vdso/gettimeofday.h
··· 6 6 7 7 #define VDSO_HAS_CLOCK_GETRES 1 8 8 9 + #define VDSO_DELTA_NOMASK 1 10 + 9 11 #include <asm/syscall.h> 10 12 #include <asm/timex.h> 11 13 #include <asm/unistd.h> 12 14 #include <linux/compiler.h> 13 15 14 - #define vdso_calc_delta __arch_vdso_calc_delta 15 - static __always_inline u64 __arch_vdso_calc_delta(u64 cycles, u64 last, u64 mask, u32 mult) 16 - { 17 - return (cycles - last) * mult; 18 - } 19 16 20 17 static __always_inline const struct vdso_data *__arch_get_vdso_data(void) 21 18 {
+8 -1
lib/vdso/gettimeofday.c
··· 6 6 #include <vdso/helpers.h> 7 7 8 8 #ifndef vdso_calc_delta 9 + 10 + #ifdef VDSO_DELTA_NOMASK 11 + # define VDSO_DELTA_MASK(mask) U64_MAX 12 + #else 13 + # define VDSO_DELTA_MASK(mask) (mask) 14 + #endif 15 + 9 16 /* 10 17 * Default implementation which works for all sane clocksources. That 11 18 * obviously excludes x86/TSC. ··· 20 13 static __always_inline 21 14 u64 vdso_calc_delta(u64 cycles, u64 last, u64 mask, u32 mult) 22 15 { 23 - return ((cycles - last) & mask) * mult; 16 + return ((cycles - last) & VDSO_DELTA_MASK(mask)) * mult; 24 17 } 25 18 #endif 26 19