From patchwork Thu Dec 31 03:03:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 7935361 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 26D099F3CD for ; Thu, 31 Dec 2015 03:07:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 53583201BB for ; Thu, 31 Dec 2015 03:07:32 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 67E1A20219 for ; Thu, 31 Dec 2015 03:07:31 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aETXo-0000PL-0z; Thu, 31 Dec 2015 03:04:52 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aETXm-0000O8-FC for xen-devel@lists.xen.org; Thu, 31 Dec 2015 03:04:50 +0000 Received: from [193.109.254.147] by server-14.bemta-14.messagelabs.com id 0C/6A-07165-15B94865; Thu, 31 Dec 2015 03:04:49 +0000 X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-16.tower-27.messagelabs.com!1451531088!13925853!1 X-Originating-IP: [192.55.52.93] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTkyLjU1LjUyLjkzID0+IDMyNDY2NQ==\n X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27539 invoked from network); 31 Dec 2015 03:04:49 -0000 Received: from mga11.intel.com (HELO mga11.intel.com) (192.55.52.93) by server-16.tower-27.messagelabs.com with SMTP; 31 Dec 2015 03:04:49 -0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 30 Dec 2015 19:04:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,503,1444719600"; d="scan'208";a="872166747" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.13.40]) by fmsmga001.fm.intel.com with ESMTP; 30 Dec 2015 19:04:38 -0800 From: Haozhong Zhang To: xen-devel@lists.xen.org, Jan Beulich , Boris Ostrovsky , Kevin Tian Date: Thu, 31 Dec 2015 11:03:32 +0800 Message-Id: <1451531020-29964-6-git-send-email-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.4.8 In-Reply-To: <1451531020-29964-1-git-send-email-haozhong.zhang@intel.com> References: <1451531020-29964-1-git-send-email-haozhong.zhang@intel.com> Cc: Haozhong Zhang , Keir Fraser , Suravee Suthikulpanit , Andrew Cooper , Aravind Gopalakrishnan , Jun Nakajima Subject: [Xen-devel] [PATCH v3 05/13] svm: Remove redundant TSC scaling in svm_set_tsc_offset() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Boris Ostrovsky --- Changes in v3: (addressing Boris Ostrovsky's comments) * Move declaration of guest_tsc to its first use site. xen/arch/x86/hvm/svm/svm.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index c538a29..8891c78 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -826,19 +826,6 @@ 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)); - } if ( !nestedhvm_enabled(d) ) { vmcb_set_tsc_offset(vmcb, offset); @@ -854,6 +841,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 ) { + uint64_t 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); }