[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Xen-devel] [PATCH 09/13] x86/time.c: Scale host TSC in pvclock properly
- To: xen-devel@xxxxxxxxxxxxx, Ian Jackson <ian.jackson@xxxxxxxxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>, Ian Campbell <ian.campbell@xxxxxxxxxx>, Wei Liu <wei.liu2@xxxxxxxxxx>, Keir Fraser <keir@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Suravee Suthikulpanit <suravee.suthikulpanit@xxxxxxx>, Aravind Gopalakrishnan <Aravind.Gopalakrishnan@xxxxxxx>, Jun Nakajima <jun.nakajima@xxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>
- From: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
- Date: Thu, 22 Oct 2015 15:15:17 -0400
- Delivery-date: Thu, 22 Oct 2015 19:15:40 +0000
- List-id: Xen developer discussion <xen-devel.lists.xen.org>
On 10/22/2015 12:44 PM, Haozhong Zhang wrote:
On Thu, Oct 22, 2015 at 11:50:18AM -0400, Boris Ostrovsky wrote:
On 09/28/2015 03:13 AM, Haozhong Zhang wrote:
This patch makes the pvclock return the scaled host TSC and
corresponding scaling parameters to HVM domains if guest TSC is not
emulated and TSC scaling is enabled.
Signed-off-by: Haozhong Zhang <haozhong.zhang@xxxxxxxxx>
---
xen/arch/x86/time.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index 4b5402c..54eab6e 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -832,10 +832,19 @@ static void __update_vcpu_system_time(struct vcpu *v, int
force)
}
else
{
- _u.tsc_timestamp = t->local_tsc_stamp;
+ if ( is_hvm_domain(d) && hvm_funcs.tsc_scaling_supported )
+ {
+ _u.tsc_timestamp = hvm_scale_tsc(v, t->local_tsc_stamp);
+ _u.tsc_to_system_mul = d->arch.vtsc_to_ns.mul_frac;
+ _u.tsc_shift = d->arch.vtsc_to_ns.shift;
+ }
+ else
+ {
+ _u.tsc_timestamp = t->local_tsc_stamp;
+ _u.tsc_to_system_mul = t->tsc_scale.mul_frac;
+ _u.tsc_shift = (s8)t->tsc_scale.shift;
+ }
_u.system_time = t->stime_local_stamp;
- _u.tsc_to_system_mul = t->tsc_scale.mul_frac;
- _u.tsc_shift = (s8)t->tsc_scale.shift;
}
if ( is_hvm_domain(d) )
_u.tsc_timestamp += v->arch.hvm_vcpu.cache_tsc_offset;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
the offset is subtract here
Ah, I missed this. Thanks.
-boris
So this is not directly related to this series but when we calculate
tsc_timestamp --- shouldn't we subtract TSC offset? Otherwise we are
reporting (possibly scaled) host's TSC and this is supposed to be guest's
counter.
-boris
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|