mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	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
This commit is contained in:
		
							parent
							
								
									82ccdf062a
								
							
						
					
					
						commit
						c8e3a8b6f2
					
				
					 3 changed files with 21 additions and 21 deletions
				
			
		| 
						 | 
					@ -13,6 +13,17 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define VDSO_HAS_TIME			1
 | 
					#define VDSO_HAS_TIME			1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * powerpc specific delta calculation.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This variant removes the masking of the subtraction because the
 | 
				
			||||||
 | 
					 * clocksource mask of all VDSO capable clocksources on powerpc is U64_MAX
 | 
				
			||||||
 | 
					 * which would result in a pointless operation. The compiler cannot
 | 
				
			||||||
 | 
					 * optimize it away as the mask comes from the vdso data and is not compile
 | 
				
			||||||
 | 
					 * time constant.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					#define VDSO_DELTA_NOMASK		1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static __always_inline int do_syscall_2(const unsigned long _r0, const unsigned long _r3,
 | 
					static __always_inline int do_syscall_2(const unsigned long _r0, const unsigned long _r3,
 | 
				
			||||||
					const unsigned long _r4)
 | 
										const unsigned long _r4)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -104,21 +115,6 @@ static inline bool vdso_clocksource_ok(const struct vdso_data *vd)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#define vdso_clocksource_ok vdso_clocksource_ok
 | 
					#define vdso_clocksource_ok vdso_clocksource_ok
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * powerpc specific delta calculation.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * This variant removes the masking of the subtraction because the
 | 
					 | 
				
			||||||
 * clocksource mask of all VDSO capable clocksources on powerpc is U64_MAX
 | 
					 | 
				
			||||||
 * which would result in a pointless operation. The compiler cannot
 | 
					 | 
				
			||||||
 * optimize it away as the mask comes from the vdso data and is not compile
 | 
					 | 
				
			||||||
 * time constant.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
static __always_inline u64 vdso_calc_delta(u64 cycles, u64 last, u64 mask, u32 mult)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return (cycles - last) * mult;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
#define vdso_calc_delta vdso_calc_delta
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef __powerpc64__
 | 
					#ifndef __powerpc64__
 | 
				
			||||||
static __always_inline u64 vdso_shift_ns(u64 ns, unsigned long shift)
 | 
					static __always_inline u64 vdso_shift_ns(u64 ns, unsigned long shift)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,16 +6,13 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define VDSO_HAS_CLOCK_GETRES 1
 | 
					#define VDSO_HAS_CLOCK_GETRES 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define VDSO_DELTA_NOMASK 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <asm/syscall.h>
 | 
					#include <asm/syscall.h>
 | 
				
			||||||
#include <asm/timex.h>
 | 
					#include <asm/timex.h>
 | 
				
			||||||
#include <asm/unistd.h>
 | 
					#include <asm/unistd.h>
 | 
				
			||||||
#include <linux/compiler.h>
 | 
					#include <linux/compiler.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define vdso_calc_delta __arch_vdso_calc_delta
 | 
					 | 
				
			||||||
static __always_inline u64 __arch_vdso_calc_delta(u64 cycles, u64 last, u64 mask, u32 mult)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return (cycles - last) * mult;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
static __always_inline const struct vdso_data *__arch_get_vdso_data(void)
 | 
					static __always_inline const struct vdso_data *__arch_get_vdso_data(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,6 +6,13 @@
 | 
				
			||||||
#include <vdso/helpers.h>
 | 
					#include <vdso/helpers.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef vdso_calc_delta
 | 
					#ifndef vdso_calc_delta
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef VDSO_DELTA_NOMASK
 | 
				
			||||||
 | 
					# define VDSO_DELTA_MASK(mask)	U64_MAX
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define VDSO_DELTA_MASK(mask)	(mask)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Default implementation which works for all sane clocksources. That
 | 
					 * Default implementation which works for all sane clocksources. That
 | 
				
			||||||
 * obviously excludes x86/TSC.
 | 
					 * obviously excludes x86/TSC.
 | 
				
			||||||
| 
						 | 
					@ -13,7 +20,7 @@
 | 
				
			||||||
static __always_inline
 | 
					static __always_inline
 | 
				
			||||||
u64 vdso_calc_delta(u64 cycles, u64 last, u64 mask, u32 mult)
 | 
					u64 vdso_calc_delta(u64 cycles, u64 last, u64 mask, u32 mult)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return ((cycles - last) & mask) * mult;
 | 
						return ((cycles - last) & VDSO_DELTA_MASK(mask)) * mult;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue