diff options
Diffstat (limited to 'arch/x86/include/asm/pvclock.h')
-rw-r--r-- | arch/x86/include/asm/pvclock.h | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h index fdcc04020636..7c1c89598688 100644 --- a/arch/x86/include/asm/pvclock.h +++ b/arch/x86/include/asm/pvclock.h | |||
@@ -69,29 +69,22 @@ static inline u64 pvclock_scale_delta(u64 delta, u32 mul_frac, int shift) | |||
69 | } | 69 | } |
70 | 70 | ||
71 | static __always_inline | 71 | static __always_inline |
72 | u64 pvclock_get_nsec_offset(const struct pvclock_vcpu_time_info *src) | ||
73 | { | ||
74 | u64 delta = rdtsc_ordered() - src->tsc_timestamp; | ||
75 | return pvclock_scale_delta(delta, src->tsc_to_system_mul, | ||
76 | src->tsc_shift); | ||
77 | } | ||
78 | |||
79 | static __always_inline | ||
80 | unsigned __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src, | 72 | unsigned __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src, |
81 | cycle_t *cycles, u8 *flags) | 73 | cycle_t *cycles, u8 *flags) |
82 | { | 74 | { |
83 | unsigned version; | 75 | unsigned version; |
84 | cycle_t ret, offset; | 76 | cycle_t offset; |
85 | u8 ret_flags; | 77 | u64 delta; |
86 | 78 | ||
87 | version = src->version; | 79 | version = src->version; |
80 | /* Make the latest version visible */ | ||
81 | smp_rmb(); | ||
88 | 82 | ||
89 | offset = pvclock_get_nsec_offset(src); | 83 | delta = rdtsc_ordered() - src->tsc_timestamp; |
90 | ret = src->system_time + offset; | 84 | offset = pvclock_scale_delta(delta, src->tsc_to_system_mul, |
91 | ret_flags = src->flags; | 85 | src->tsc_shift); |
92 | 86 | *cycles = src->system_time + offset; | |
93 | *cycles = ret; | 87 | *flags = src->flags; |
94 | *flags = ret_flags; | ||
95 | return version; | 88 | return version; |
96 | } | 89 | } |
97 | 90 | ||