From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 1/6] KVM: SVM: Implement infrastructure for TSC_RATE_MSR Date: Thu, 24 Mar 2011 11:51:59 +0200 Message-ID: <4D8B143F.9080400@redhat.com> References: <1300952424-32014-1-git-send-email-joerg.roedel@amd.com> <1300952424-32014-2-git-send-email-joerg.roedel@amd.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , Zachary Amsden , kvm@vger.kernel.org To: Joerg Roedel Return-path: Received: from mx1.redhat.com ([209.132.183.28]:18446 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754961Ab1CXJwE (ORCPT ); Thu, 24 Mar 2011 05:52:04 -0400 In-Reply-To: <1300952424-32014-2-git-send-email-joerg.roedel@amd.com> Sender: kvm-owner@vger.kernel.org List-ID: On 03/24/2011 09:40 AM, Joerg Roedel wrote: > This patch enhances the kvm_amd module with functions to > support the TSC_RATE_MSR which can be used to set a given > tsc frequency for the guest vcpu. > > > @@ -1141,6 +1175,9 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu) > > for (i = 0; i< NR_HOST_SAVE_USER_MSRS; i++) > rdmsrl(host_save_user_msrs[i], svm->host_user_msrs[i]); > + > + if (static_cpu_has(X86_FEATURE_TSCRATEMSR)&& svm->tsc_scale.enabled) > + wrmsrl(MSR_AMD64_TSC_RATIO, svm->tsc_scale.ratio); > } > > static void svm_vcpu_put(struct kvm_vcpu *vcpu) > @@ -1161,6 +1198,9 @@ static void svm_vcpu_put(struct kvm_vcpu *vcpu) > #endif > for (i = 0; i< NR_HOST_SAVE_USER_MSRS; i++) > wrmsrl(host_save_user_msrs[i], svm->host_user_msrs[i]); > + > + if (static_cpu_has(X86_FEATURE_TSCRATEMSR)&& svm->tsc_scale.enabled) > + wrmsr(MSR_AMD64_TSC_RATIO, 0, 1); > } This is a bit suboptimal. We could do something like static DEFINE_PER_CPU(u64, current_tsc_scale); static void svm_vcpu_load(...) { ... if (svm->tsc_scale != __get_cpu_var(current_tsc_scale)) { __get_cpu_var(current_tsc_scale) = svm->tsc_scale; wrmsrl(MSR_AMD64_TSC_RATIO, svm->tsc_scale); } } with no changes to svm_vcpu_put() (note no tsc_scale.enabled either, just put the unity value for disabled). -- error compiling committee.c: too many arguments to function