From: Paolo Bonzini <pbonzini@redhat.com>
To: Owen Hofmann <osh@google.com>, kvm@vger.kernel.org
Cc: Haozhong Zhang <haozhong.zhang@intel.com>
Subject: Re: [PATCH] kvm: x86: Update tsc multiplier on change.
Date: Wed, 2 Mar 2016 10:38:42 +0100 [thread overview]
Message-ID: <56D6B4A2.9050909@redhat.com> (raw)
In-Reply-To: <1456868173-444-1-git-send-email-osh@google.com>
On 01/03/2016 22:36, Owen Hofmann wrote:
> vmx.c writes the TSC_MULTIPLIER field in vmx_vcpu_load, but only when a
> vcpu has migrated physical cpus. Record the last value written and
> update in vmx_vcpu_load on any change, otherwise a cpu migration must
> occur for TSC frequency scaling to take effect.
>
> Fixes: ff2c3a1803775cc72dc6f624b59554956396b0ee
> Signed-off-by: Owen Hofmann <osh@google.com>
> ---
> arch/x86/kvm/vmx.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index e2951b6..0ff4537 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -596,6 +596,8 @@ struct vcpu_vmx {
> /* Support for PML */
> #define PML_ENTITY_NUM 512
> struct page *pml_pg;
> +
> + u64 current_tsc_ratio;
> };
>
> enum segment_cache_field {
> @@ -2127,14 +2129,16 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
> rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
> vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
>
> - /* Setup TSC multiplier */
> - if (cpu_has_vmx_tsc_scaling())
> - vmcs_write64(TSC_MULTIPLIER,
> - vcpu->arch.tsc_scaling_ratio);
> -
> vmx->loaded_vmcs->cpu = cpu;
> }
>
> + /* Setup TSC multiplier */
> + if (kvm_has_tsc_control &&
> + vmx->current_tsc_ratio != vcpu->arch.tsc_scaling_ratio) {
> + vmx->current_tsc_ratio = vcpu->arch.tsc_scaling_ratio;
> + vmcs_write64(TSC_MULTIPLIER, vmx->current_tsc_ratio);
> + }
> +
> vmx_vcpu_pi_load(vcpu, cpu);
> }
>
>
Applied for 4.5 and Cc: stable@vger.kernel.org.
Paolo
prev parent reply other threads:[~2016-03-02 9:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-01 21:36 [PATCH] kvm: x86: Update tsc multiplier on change Owen Hofmann
2016-03-02 1:39 ` Haozhong Zhang
2016-03-02 9:38 ` Paolo Bonzini [this message]
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=56D6B4A2.9050909@redhat.com \
--to=pbonzini@redhat.com \
--cc=haozhong.zhang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=osh@google.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.