diff mbox

[v3,05/13] svm: Remove redundant TSC scaling in svm_set_tsc_offset()

Message ID 1451531020-29964-6-git-send-email-haozhong.zhang@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Haozhong Zhang Dec. 31, 2015, 3:03 a.m. UTC
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 <haozhong.zhang@intel.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
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(-)

Comments

Jan Beulich Jan. 8, 2016, 9:22 a.m. UTC | #1
>>> On 31.12.15 at 04:03, <haozhong.zhang@intel.com> wrote:
> @@ -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,

Blank line between declaration(s) and statement(s) please.

Also please consider taking the opportunity to fix the preceding
line's coding style violation.

Jan
Haozhong Zhang Jan. 8, 2016, 1:24 p.m. UTC | #2
On 01/08/16 02:22, Jan Beulich wrote:
> >>> On 31.12.15 at 04:03, <haozhong.zhang@intel.com> wrote:
> > @@ -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,
> 
> Blank line between declaration(s) and statement(s) please.
> 
> Also please consider taking the opportunity to fix the preceding
> line's coding style violation.
> 
> Jan

OK, both will be fixed in the next version.

Haozhong
diff mbox

Patch

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);
         }