From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751665AbbJFByK (ORCPT ); Mon, 5 Oct 2015 21:54:10 -0400 Received: from mga09.intel.com ([134.134.136.24]:12767 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751238AbbJFByI (ORCPT ); Mon, 5 Oct 2015 21:54:08 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,641,1437462000"; d="scan'208";a="785311675" Date: Tue, 6 Oct 2015 09:54:04 +0800 From: Haozhong Zhang To: Radim =?utf-8?B?S3LEjW3DocWZ?= 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 Subject: Re: [PATCH 02/12] KVM: x86: Add a common TSC scaling ratio field in kvm_vcpu_arch Message-ID: <20151006015404.GC3798@hzzhang-OptiPlex-9020.sh.intel.com> Mail-Followup-To: Radim =?utf-8?B?S3LEjW3DocWZ?= , 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 References: <1443418691-24050-1-git-send-email-haozhong.zhang@intel.com> <1443418691-24050-3-git-send-email-haozhong.zhang@intel.com> <20151005192630.GA25653@potion.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20151005192630.GA25653@potion.brq.redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 05, 2015 at 09:26:30PM +0200, Radim Krčmář wrote: > 2015-09-28 13:38+0800, Haozhong Zhang: > > This patch moves the field of TSC scaling ratio from the architecture > > struct vcpu_svm to the common struct kvm_vcpu_arch. > > > > Signed-off-by: Haozhong Zhang > > --- > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > > @@ -7080,6 +7080,9 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, > > > > vcpu = kvm_x86_ops->vcpu_create(kvm, id); > > > > + if (!IS_ERR(vcpu)) > > + vcpu->arch.tsc_scaling_ratio = kvm_default_tsc_scaling_ratio; > > This shouldn't be necessary, (and we can definitely do it without error > checking later) > > kvm_arch_vcpu_create > (vmx|svm)_create_vcpu > kvm_vcpu_init > kvm_arch_vcpu_init > kvm_set_tsc_khz > > sets vcpu->arch.tsc_scaling_ratio to something reasonable and SVM didn't > overwrite that value. (kvm_set_tsc_khz() only doesn't set the ration if > this_tsc_khz == 0, which we could extend to be extra safe.) Thanks Radim! I even didn't notice this path. I'll remove the ratio setting in kvm_arch_vcpu_create(). In kvm_set_tsc_khz(), if this_tsc_khz == 0, I'll make it set vcpu->arch.tsc_scaling_ratio to kvm_default_tsc_scaling_ratio. - Haozhong