Commit f7550d07 authored by Minfei Huang's avatar Minfei Huang Committed by Paolo Bonzini

pvclock: Cleanup to remove function pvclock_get_nsec_offset

Function __pvclock_read_cycles is short enough, so there is no need to
have another function pvclock_get_nsec_offset to calculate tsc delta.
It's better to combine it into function __pvclock_read_cycles.

Remove useless variables in function __pvclock_read_cycles.
Signed-off-by: default avatarMinfei Huang <mnghuan@gmail.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 749d088b
...@@ -68,32 +68,23 @@ static inline u64 pvclock_scale_delta(u64 delta, u32 mul_frac, int shift) ...@@ -68,32 +68,23 @@ static inline u64 pvclock_scale_delta(u64 delta, u32 mul_frac, int shift)
return product; return product;
} }
static __always_inline
u64 pvclock_get_nsec_offset(const struct pvclock_vcpu_time_info *src)
{
u64 delta = rdtsc_ordered() - src->tsc_timestamp;
return pvclock_scale_delta(delta, src->tsc_to_system_mul,
src->tsc_shift);
}
static __always_inline static __always_inline
unsigned __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src, unsigned __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src,
cycle_t *cycles, u8 *flags) cycle_t *cycles, u8 *flags)
{ {
unsigned version; unsigned version;
cycle_t ret, offset; cycle_t offset;
u8 ret_flags; u64 delta;
version = src->version; version = src->version;
/* Make the latest version visible */ /* Make the latest version visible */
smp_rmb(); smp_rmb();
offset = pvclock_get_nsec_offset(src); delta = rdtsc_ordered() - src->tsc_timestamp;
ret = src->system_time + offset; offset = pvclock_scale_delta(delta, src->tsc_to_system_mul,
ret_flags = src->flags; src->tsc_shift);
*cycles = src->system_time + offset;
*cycles = ret; *flags = src->flags;
*flags = ret_flags;
return version; return version;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment