From mboxrd@z Thu Jan 1 00:00:00 1970 From: Haozhong Zhang Subject: Re: [PATCH v2 07/14] svm: Remove redundant TSC scaling in svm_set_tsc_offset() Date: Tue, 8 Dec 2015 09:54:37 +0800 Message-ID: <20151208015437.GG3547@hz-desktop.sh.intel.com> References: <1449435529-12989-1-git-send-email-haozhong.zhang@intel.com> <1449435529-12989-8-git-send-email-haozhong.zhang@intel.com> <5665CF13.8060707@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: <5665CF13.8060707@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 , Keir Fraser , Jan Beulich , Jun Nakajima , Andrew Cooper , xen-devel@lists.xen.org, Aravind Gopalakrishnan , Suravee Suthikulpanit List-Id: xen-devel@lists.xenproject.org On 12/07/15 13:25, Boris Ostrovsky wrote: > On 12/06/2015 03:58 PM, Haozhong Zhang wrote: > >Now every caller passes an already scaled offset to > >svm_set_tsc_offset(), so it's not necessary to recalculate a scaled TSC > >offset in svm_set_tsc_offset(). > > > >Signed-off-by: Haozhong Zhang > >--- > > xen/arch/x86/hvm/svm/svm.c | 15 ++------------- > > 1 file changed, 2 insertions(+), 13 deletions(-) > > > >diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c > >index 9d5f2c3..3d22dfa 100644 > >--- a/xen/arch/x86/hvm/svm/svm.c > >+++ b/xen/arch/x86/hvm/svm/svm.c > >@@ -826,19 +826,7 @@ static void svm_set_tsc_offset(struct vcpu *v, u64 offset, u64 at_tsc) > > struct vmcb_struct *n1vmcb, *n2vmcb; > > uint64_t n2_tsc_offset = 0; > > struct domain *d = v->domain; > >- uint64_t host_tsc, guest_tsc; > >- > >- guest_tsc = hvm_get_guest_tsc_fixed(v, at_tsc); > >- > >- /* Re-adjust the offset value when TSC_RATIO is available */ > >- if ( cpu_has_tsc_ratio && !d->arch.vtsc ) > >- { > >- if ( at_tsc ) > >- host_tsc = at_tsc; > >- else > >- host_tsc = rdtsc(); > >- offset = svm_get_tsc_offset(host_tsc, guest_tsc, vcpu_tsc_ratio(v)); > >- } > >+ uint64_t guest_tsc; > > You could declare it at the first use site below. > will move to the first use site. Haozhong > Other than that, > > Reviewed-by: Boris Ostrovsky > > > if ( !nestedhvm_enabled(d) ) { > > vmcb_set_tsc_offset(vmcb, offset); > >@@ -854,6 +842,7 @@ static void svm_set_tsc_offset(struct vcpu *v, u64 offset, u64 at_tsc) > > n2_tsc_offset = vmcb_get_tsc_offset(n2vmcb) - > > vmcb_get_tsc_offset(n1vmcb); > > if ( svm->ns_tscratio != DEFAULT_TSC_RATIO ) { > >+ guest_tsc = hvm_get_guest_tsc_fixed(v, at_tsc); > > n2_tsc_offset = svm_get_tsc_offset(guest_tsc, > > guest_tsc + n2_tsc_offset, svm->ns_tscratio); > > } >