2 * linux/include/asm-i386/tsc.h
4 * i386 TSC related functions
6 #ifndef _ASM_i386_TSC_H
7 #define _ASM_i386_TSC_H
9 #include <asm/processor.h>
12 * Standard way to access the cycle counter.
14 typedef unsigned long long cycles_t
;
16 extern unsigned int cpu_khz
;
17 extern unsigned int tsc_khz
;
19 static inline cycles_t
get_cycles(void)
21 unsigned long long ret
= 0;
23 #ifndef CONFIG_X86_TSC
28 #if defined(CONFIG_X86_GENERIC) || defined(CONFIG_X86_TSC)
34 /* Like get_cycles, but make sure the CPU is synchronized. */
35 static __always_inline cycles_t
get_cycles_sync(void)
37 unsigned long long ret
;
41 * Use RDTSCP if possible; it is guaranteed to be synchronous
42 * and doesn't cause a VMEXIT on Hypervisors
44 alternative_io(ASM_NOP3
, ".byte 0x0f,0x01,0xf9", X86_FEATURE_RDTSCP
,
45 ASM_OUTPUT2("=a" (eax
), "=d" (edx
)),
46 "a" (0U), "d" (0U) : "ecx", "memory");
47 ret
= (((unsigned long long)edx
) << 32) | ((unsigned long long)eax
);
52 * Don't do an additional sync on CPUs where we know
53 * RDTSC is already synchronous:
55 alternative_io("cpuid", ASM_NOP2
, X86_FEATURE_SYNC_RDTSC
,
56 "=a" (eax
), "0" (1) : "ebx","ecx","edx","memory");
62 extern void tsc_init(void);
63 extern void mark_tsc_unstable(char *reason
);
64 extern int unsynchronized_tsc(void);
65 extern void init_tsc_clocksource(void);
66 int check_tsc_unstable(void);
69 * Boot-time check whether the TSCs are synchronized across
72 extern void check_tsc_sync_source(int cpu
);
73 extern void check_tsc_sync_target(void);