[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] x86/time: use correct guest TSC frequency in tsc_set_info()
commit 0a449aa43d88164789b3f60ed3bbd64dae897da8 Author: Haozhong Zhang <haozhong.zhang@xxxxxxxxx> AuthorDate: Fri Jan 8 10:48:10 2016 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Fri Jan 8 10:48:10 2016 +0100 x86/time: use correct guest TSC frequency in tsc_set_info() When TSC_MODE_PVRDTSCP is used for a HVM container and TSC scaling is available, use the non-zero value of argument gtsc_khz of tsc_set_info() as the guest TSC frequency rather than using the host TSC frequency. Otherwise, TSC scaling will not be able get the correct ratio between the host and guest TSC frequencies. Signed-off-by: Haozhong Zhang <haozhong.zhang@xxxxxxxxx> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx> --- xen/arch/x86/time.c | 9 +++++++-- xen/include/asm-x86/domain.h | 9 ++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index b5223cf..ee4d755 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1838,6 +1838,8 @@ void tsc_set_info(struct domain *d, switch ( d->arch.tsc_mode = tsc_mode ) { + bool_t enable_tsc_scaling; + case TSC_MODE_DEFAULT: case TSC_MODE_ALWAYS_EMULATE: d->arch.vtsc_offset = get_s_time() - elapsed_nsec; @@ -1864,7 +1866,9 @@ void tsc_set_info(struct domain *d, case TSC_MODE_PVRDTSCP: d->arch.vtsc = !boot_cpu_has(X86_FEATURE_RDTSCP) || !host_tsc_is_safe(); - d->arch.tsc_khz = cpu_khz; + enable_tsc_scaling = has_hvm_container_domain(d) && + cpu_has_tsc_ratio && !d->arch.vtsc; + d->arch.tsc_khz = (enable_tsc_scaling && gtsc_khz) ? gtsc_khz : cpu_khz; set_time_scale(&d->arch.vtsc_to_ns, d->arch.tsc_khz * 1000 ); d->arch.ns_to_vtsc = scale_reciprocal(d->arch.vtsc_to_ns); if ( d->arch.vtsc ) @@ -1872,7 +1876,8 @@ void tsc_set_info(struct domain *d, else { /* when using native TSC, offset is nsec relative to power-on * of physical machine */ - d->arch.vtsc_offset = scale_delta(rdtsc(), &d->arch.vtsc_to_ns) - + d->arch.vtsc_offset = scale_delta(rdtsc(), + &this_cpu(cpu_time).tsc_scale) - elapsed_nsec; } break; diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index e8f7037..405adef 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -347,9 +347,12 @@ struct arch_domain s_time_t vtsc_last; /* previous TSC value (guarantee monotonicity) */ spinlock_t vtsc_lock; uint64_t vtsc_offset; /* adjustment for save/restore/migrate */ - uint32_t tsc_khz; /* cached khz for certain emulated cases */ - struct time_scale vtsc_to_ns; /* scaling for certain emulated cases */ - struct time_scale ns_to_vtsc; /* scaling for certain emulated cases */ + uint32_t tsc_khz; /* cached guest khz for certain emulated or + hardware TSC scaling cases */ + struct time_scale vtsc_to_ns; /* scaling for certain emulated or + hardware TSC scaling cases */ + struct time_scale ns_to_vtsc; /* scaling for certain emulated or + hardware TSC scaling cases */ uint32_t incarnation; /* incremented every restore or live migrate (possibly other cases in the future */ #if !defined(NDEBUG) || defined(PERF_COUNTERS) -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |