[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2 03/14] x86/time.c: Use correct guest TSC frequency in tsc_set_info()
On 12/07/15 11:57, Boris Ostrovsky wrote: > On 12/06/2015 03:58 PM, Haozhong Zhang wrote: > >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> > >--- > > xen/arch/x86/time.c | 11 +++++++++-- > > 1 file changed, 9 insertions(+), 2 deletions(-) > > > >diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c > >index b5223cf..1091e69 100644 > >--- a/xen/arch/x86/time.c > >+++ b/xen/arch/x86/time.c > >@@ -1803,6 +1803,8 @@ void tsc_set_info(struct domain *d, > > uint32_t tsc_mode, uint64_t elapsed_nsec, > > uint32_t gtsc_khz, uint32_t incarnation) > > { > >+ bool_t enable_tsc_scaling; > >+ > > if ( is_idle_domain(d) || is_hardware_domain(d) ) > > { > > d->arch.vtsc = 0; > >@@ -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,10 @@ 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) > >- > >+ struct time_scale *scale = enable_tsc_scaling ? > > Do we need this test here? Per previous chunk, enable_tsc_scaling will be > zero since d->arch.vtsc is false. > > Actually, if you are trying to use (or, rather, account for) TSC scaling, > shouldn't it be !arch.vtsc there? > It really should be !arch.vtsc. Don't know why I missed ! here but my testing code did not. Thanks, Haozhong _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |