From: Joerg Roedel <joro@8bytes.org>
To: Avi Kivity <avi@redhat.com>
Cc: Joerg Roedel <joerg.roedel@amd.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
Zachary Amsden <zamsden@redhat.com>,
kvm@vger.kernel.org
Subject: Re: [PATCH 1/6] KVM: SVM: Implement infrastructure for TSC_RATE_MSR
Date: Thu, 24 Mar 2011 10:58:28 +0100 [thread overview]
Message-ID: <20110324095828.GE18867@8bytes.org> (raw)
In-Reply-To: <4D8B143F.9080400@redhat.com>
On Thu, Mar 24, 2011 at 11:51:59AM +0200, Avi Kivity wrote:
> 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).
Right, this is a good optimization. Thanks for the hint, I'll change it.
Regards,
Joerg
next prev parent reply other threads:[~2011-03-24 9:58 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-24 7:40 [PATCH 0/6][RESEND] TSC scaling support for KVM v2 Joerg Roedel
2011-03-24 7:40 ` [PATCH 1/6] KVM: SVM: Implement infrastructure for TSC_RATE_MSR Joerg Roedel
2011-03-24 9:51 ` Avi Kivity
2011-03-24 9:58 ` Joerg Roedel [this message]
2011-03-24 7:40 ` [PATCH 2/6] KVM: X86: Let kvm-clock report the right tsc frequency Joerg Roedel
2011-03-24 9:58 ` Avi Kivity
2011-03-24 7:40 ` [PATCH 3/6] KVM: X86: Make tsc_delta calculation a function of guest tsc Joerg Roedel
2011-03-24 7:40 ` [PATCH 4/6] KVM: SVM: Propagate requested TSC frequency on vcpu init Joerg Roedel
2011-03-24 10:04 ` Avi Kivity
2011-03-24 10:21 ` Joerg Roedel
2011-03-24 10:30 ` Avi Kivity
2011-03-24 7:40 ` [PATCH 5/6] KVM: X86: Delegate tsc-offset calculation to architecture code Joerg Roedel
2011-03-24 7:40 ` [PATCH 6/6] KVM: X86: Implement userspace interface to set virtual_tsc_khz Joerg Roedel
2011-03-24 10:14 ` Avi Kivity
2011-03-24 10:41 ` Joerg Roedel
2011-03-24 10:44 ` Avi Kivity
2011-03-24 10:47 ` Joerg Roedel
-- strict thread matches above, loose matches on Subject: below --
2011-03-25 8:44 [PATCH 0/6] TSC scaling support for KVM v3 Joerg Roedel
2011-03-25 8:44 ` [PATCH 1/6] KVM: SVM: Implement infrastructure for TSC_RATE_MSR Joerg Roedel
2011-03-15 9:36 [PATCH 0/6] TSC scaling support for KVM v2 Joerg Roedel
2011-03-15 9:36 ` [PATCH 1/6] KVM: SVM: Implement infrastructure for TSC_RATE_MSR Joerg Roedel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110324095828.GE18867@8bytes.org \
--to=joro@8bytes.org \
--cc=avi@redhat.com \
--cc=joerg.roedel@amd.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=zamsden@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.