linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Haozhong Zhang <haozhong.zhang@intel.com>, kvm@vger.kernel.org
Cc: Gleb Natapov <gleb@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Joerg Roedel <joro@8bytes.org>,
	Wanpeng Li <wanpeng.li@hotmail.com>,
	Xiao Guangrong <guangrong.xiao@linux.intel.com>,
	mdontu@bitdefender.com, Kai Huang <kai.huang@linux.intel.com>,
	Andy Lutomirski <luto@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 00/12] KVM: x86: add support for VMX TSC scaling
Date: Fri, 6 Nov 2015 11:49:08 +0100	[thread overview]
Message-ID: <563C85A4.1080006@redhat.com> (raw)
In-Reply-To: <1445326752-8926-1-git-send-email-haozhong.zhang@intel.com>



On 20/10/2015 09:39, Haozhong Zhang wrote:
> This patchset adds support for VMX TSC scaling feature which is
> available on Intel Skylake CPU. The specification of VMX TSC scaling
> can be found at
> http://www.intel.com/content/www/us/en/processors/timestamp-counter-scaling-virtualization-white-paper.html
> 
> VMX TSC scaling allows guest TSC which is read by guest rdtsc(p)
> instructions increases in a rate that is customized by the hypervisor
> and can be different than the host TSC rate. Basically, VMX TSC
> scaling adds a 64-bit field called TSC multiplier in VMCS so that, if
> VMX TSC scaling is enabled, TSC read by guest rdtsc(p) instructions
> will be calculated by the following formula:
> 
>   guest EDX:EAX = (Host TSC * TSC multiplier) >> 48 + VMX TSC Offset
> 
> where, Host TSC = Host MSR_IA32_TSC + Host MSR_IA32_TSC_ADJUST.
> 
> This patchset, when cooperating with another QEMU patchset (sent in
> another email "target-i386: save/restore vcpu's TSC rate during
> migration"), allows guest programs observe a consistent TSC rate even
> though they are migrated among machines with different host TSC rates.
> 
> VMX TSC scaling shares some common logics with SVM TSC ratio which
> is already supported by KVM. Patch 1 ~ 8 move those common logics from
> SVM code to the common code. Upon them, patch 9 ~ 12 add VMX-specific
> support for VMX TSC scaling.
> 
> Changes in v2:
>  * Remove the duplicated variable 'kvm_tsc_scaling_ratio_rsvd'.
>  * Remove an unnecessary error check in original patch 2.
>  * Do 64-bit arithmetic by functions recommended by Paolo.
>  * Make kvm_set_tsc_khz() returns an error number so that ioctl
>    KVM_SET_TSC_KHZ does not return 0 if errors happen.
> 
> Reviewed-by: Eric Northup <digitaleric@google.com>

Thanks for the patches.  There are a couple changes that I can do myself:

1) kvm_default_tsc_scaling_ratio can be initialized in
kvm_arch_hardware_setup, since it's just 1ULL <<
kvm_tsc_scaling_ratio_frac_bits

2) things that you are adding to include/linux/kvm_host.h should instead
go in arch/x86/include/linux/kvm_host.h

That's it.  I'll commit it as soon as I test on AMD (today hopefully).

Paolo

> Haozhong Zhang (12):
>   KVM: x86: Collect information for setting TSC scaling ratio
>   KVM: x86: Add a common TSC scaling ratio field in kvm_vcpu_arch
>   KVM: x86: Add a common TSC scaling function
>   KVM: x86: Replace call-back set_tsc_khz() with a common function
>   KVM: x86: Replace call-back compute_tsc_offset() with a common function
>   KVM: x86: Move TSC scaling logic out of call-back adjust_tsc_offset()
>   KVM: x86: Move TSC scaling logic out of call-back read_l1_tsc()
>   KVM: x86: Use the correct vcpu's TSC rate to compute time scale
>   KVM: VMX: Enable and initialize VMX TSC scaling
>   KVM: VMX: Setup TSC scaling ratio when a vcpu is loaded
>   KVM: VMX: Use a scaled host TSC for guest readings of MSR_IA32_TSC
>   KVM: VMX: Dump TSC multiplier in dump_vmcs()
> 
>  arch/x86/include/asm/kvm_host.h |  24 +++----
>  arch/x86/include/asm/vmx.h      |   3 +
>  arch/x86/kvm/lapic.c            |   4 +-
>  arch/x86/kvm/svm.c              | 116 ++++------------------------------
>  arch/x86/kvm/vmx.c              |  64 ++++++++++---------
>  arch/x86/kvm/x86.c              | 134 +++++++++++++++++++++++++++++++++++-----
>  include/linux/kvm_host.h        |  20 ++++++
>  include/linux/math64.h          |  99 +++++++++++++++++++++++++++++
>  8 files changed, 297 insertions(+), 167 deletions(-)
> 

  parent reply	other threads:[~2015-11-06 10:49 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-20  7:39 [PATCH v2 00/12] KVM: x86: add support for VMX TSC scaling Haozhong Zhang
2015-10-20  7:39 ` [PATCH v2 01/12] KVM: x86: Collect information for setting TSC scaling ratio Haozhong Zhang
2015-10-20  7:39 ` [PATCH v2 02/12] KVM: x86: Add a common TSC scaling ratio field in kvm_vcpu_arch Haozhong Zhang
2015-10-20  7:39 ` [PATCH v2 03/12] KVM: x86: Add a common TSC scaling function Haozhong Zhang
2015-10-20  7:39 ` [PATCH v2 04/12] KVM: x86: Replace call-back set_tsc_khz() with a common function Haozhong Zhang
2015-10-20  7:39 ` [PATCH v2 05/12] KVM: x86: Replace call-back compute_tsc_offset() " Haozhong Zhang
2015-10-20  7:39 ` [PATCH v2 06/12] KVM: x86: Move TSC scaling logic out of call-back adjust_tsc_offset() Haozhong Zhang
2015-10-20  7:39 ` [PATCH v2 07/12] KVM: x86: Move TSC scaling logic out of call-back read_l1_tsc() Haozhong Zhang
2015-10-20  7:39 ` [PATCH v2 08/12] KVM: x86: Use the correct vcpu's TSC rate to compute time scale Haozhong Zhang
2015-10-20  7:39 ` [PATCH v2 09/12] KVM: VMX: Enable and initialize VMX TSC scaling Haozhong Zhang
2015-10-20  7:39 ` [PATCH v2 10/12] KVM: VMX: Setup TSC scaling ratio when a vcpu is loaded Haozhong Zhang
2015-10-20  7:39 ` [PATCH v2 11/12] KVM: VMX: Use a scaled host TSC for guest readings of MSR_IA32_TSC Haozhong Zhang
2015-10-20  7:39 ` [PATCH v2 12/12] KVM: VMX: Dump TSC multiplier in dump_vmcs() Haozhong Zhang
2015-10-23 10:06 ` [PATCH v2 00/12] KVM: x86: add support for VMX TSC scaling Joerg Roedel
2015-10-23 12:32   ` Haozhong Zhang
2015-10-23 12:46     ` Joerg Roedel
2015-10-23 12:51       ` Paolo Bonzini
2015-10-23 14:37         ` Haozhong Zhang
2015-10-23 12:55       ` Haozhong Zhang
2015-10-23 14:31 ` Haozhong Zhang
2015-11-06 10:49 ` Paolo Bonzini [this message]
2015-11-06 12:42   ` Haozhong Zhang
2015-11-06 20:40     ` Paolo Bonzini
2015-11-09  0:06       ` haozhong.zhang

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=563C85A4.1080006@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=gleb@kernel.org \
    --cc=guangrong.xiao@linux.intel.com \
    --cc=haozhong.zhang@intel.com \
    --cc=hpa@zytor.com \
    --cc=joro@8bytes.org \
    --cc=kai.huang@linux.intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mdontu@bitdefender.com \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=wanpeng.li@hotmail.com \
    --cc=x86@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).