From: Haozhong Zhang Subject: Re: [PATCH 09/13] x86/time.c: Scale host TSC in pvclock properly Date: Tue, 29 Sep 2015 08:19:31 +0800 Message-ID: <20150929001931.GA3583@hzzhang-OptiPlex-9020.sh.intel.com> References: <1443424438-13404-1-git-send-email-haozhong.zhang@intel.com> <1443424438-13404-10-git-send-email-haozhong.zhang@intel.com> <56096CA3.5000405@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <56096CA3.5000405@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Boris Ostrovsky Cc: Kevin Tian , Wei Liu , Ian Campbell , Stefano Stabellini , Jun Nakajima , Andrew Cooper , Ian Jackson , xen-devel@lists.xen.org, Aravind Gopalakrishnan , Jan Beulich , Keir Fraser , Suravee Suthikulpanit List-Id: xen-devel@lists.xenproject.org On Mon, Sep 28, 2015 at 12:36:51PM -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 > >--- > > 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 ) > > This should probably be has_hvm_container_domain(d). > > And I think you also may need to adjust this in patch 4 (tsc_set_info()). > Yes, I'll change them to has_hvm_container_domain() in next version. > -boris > > > >+ { > >+ _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; > - Haozhong Zhang