From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH 08/12] KVM: x86: Use the correct vcpu's TSC rate to compute time scale Date: Mon, 5 Oct 2015 22:12:34 +0200 Message-ID: <20151005201233.GA31314@potion.brq.redhat.com> References: <1443418691-24050-1-git-send-email-haozhong.zhang@intel.com> <1443418691-24050-9-git-send-email-haozhong.zhang@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, Gleb Natapov , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Joerg Roedel , Wanpeng Li , Xiao Guangrong , Mihai =?utf-8?B?RG9uyJt1?= , Andy Lutomirski , Kai Huang , linux-kernel@vger.kernel.org To: Haozhong Zhang Return-path: Received: from mx1.redhat.com ([209.132.183.28]:47561 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752631AbbJEUMj (ORCPT ); Mon, 5 Oct 2015 16:12:39 -0400 Content-Disposition: inline In-Reply-To: <1443418691-24050-9-git-send-email-haozhong.zhang@intel.com> Sender: kvm-owner@vger.kernel.org List-ID: 2015-09-28 13:38+0800, Haozhong Zhang: > This patch makes KVM use virtual_tsc_khz rather than the host TSC rate > as vcpu's TSC rate to compute the time scale if TSC scaling is enabled. > > Signed-off-by: Haozhong Zhang > --- > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > @@ -1782,7 +1782,9 @@ static int kvm_guest_time_update(struct kvm_vcpu *v) > return 0; > > if (unlikely(vcpu->hw_tsc_khz != this_tsc_khz)) { > - kvm_get_time_scale(NSEC_PER_SEC / 1000, this_tsc_khz, > + tgt_tsc_khz = kvm_has_tsc_control ? > + vcpu->virtual_tsc_khz : this_tsc_khz; > + kvm_get_time_scale(NSEC_PER_SEC / 1000, tgt_tsc_khz, > &vcpu->hv_clock.tsc_shift, > &vcpu->hv_clock.tsc_to_system_mul); Good catch, it seems that SVM didn't scale kvmclock correctly ... I think we'll want this patch in stable.