Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1233849 > unrolled thread
| Started by | Haozhong Zhang <haozhong.zhang@intel.com> |
|---|---|
| First post | 2015-09-28 07:40 +0200 |
| Last post | 2015-09-29 06:10 +0200 |
| Articles | 4 on this page of 24 — 5 participants |
Back to article view | Back to linux.kernel
[PATCH 00/12] KVM: x86: add support for VMX TSC scaling Haozhong Zhang <haozhong.zhang@intel.com> - 2015-09-28 07:40 +0200
[PATCH 07/12] KVM: x86: Move TSC scaling logic out of call-back read_l1_tsc() Haozhong Zhang <haozhong.zhang@intel.com> - 2015-09-28 07:40 +0200
[PATCH 11/12] KVM: VMX: Use a scaled host TSC for guest readings of MSR_IA32_TSC Haozhong Zhang <haozhong.zhang@intel.com> - 2015-09-28 07:40 +0200
[PATCH 06/12] KVM: x86: Move TSC scaling logic out of call-back adjust_tsc_offset() Haozhong Zhang <haozhong.zhang@intel.com> - 2015-09-28 07:40 +0200
Re: [PATCH 06/12] KVM: x86: Move TSC scaling logic out of call-back adjust_tsc_offset() Paolo Bonzini <pbonzini@redhat.com> - 2015-09-28 22:20 +0200
Re: [PATCH 06/12] KVM: x86: Move TSC scaling logic out of call-back adjust_tsc_offset() Haozhong Zhang <haozhong.zhang@intel.com> - 2015-09-29 03:50 +0200
[PATCH 01/12] KVM: x86: Collect information for setting TSC scaling ratio Haozhong Zhang <haozhong.zhang@intel.com> - 2015-09-28 07:40 +0200
Re: [PATCH 01/12] KVM: x86: Collect information for setting TSC scaling ratio Eric Northup <digitaleric@google.com> - 2015-09-29 05:30 +0200
Re: [PATCH 01/12] KVM: x86: Collect information for setting TSC scaling ratio Haozhong Zhang <haozhong.zhang@intel.com> - 2015-09-29 06:10 +0200
[PATCH 02/12] KVM: x86: Add a common TSC scaling ratio field in kvm_vcpu_arch Haozhong Zhang <haozhong.zhang@intel.com> - 2015-09-28 07:50 +0200
Re: [PATCH 02/12] KVM: x86: Add a common TSC scaling ratio field in kvm_vcpu_arch Radim Krčmář <rkrcmar@redhat.com> - 2015-10-05 21:30 +0200
[PATCH 08/12] KVM: x86: Use the correct vcpu's TSC rate to compute time scale Haozhong Zhang <haozhong.zhang@intel.com> - 2015-09-28 07:50 +0200
Re: [PATCH 08/12] KVM: x86: Use the correct vcpu's TSC rate to compute time scale Radim Krčmář <rkrcmar@redhat.com> - 2015-10-05 22:20 +0200
[PATCH 05/12] KVM: x86: Replace call-back compute_tsc_offset() with a common function Haozhong Zhang <haozhong.zhang@intel.com> - 2015-09-28 07:50 +0200
[PATCH 03/12] KVM: x86: Add a common TSC scaling function Haozhong Zhang <haozhong.zhang@intel.com> - 2015-09-28 07:50 +0200
Re: [PATCH 03/12] KVM: x86: Add a common TSC scaling function Paolo Bonzini <pbonzini@redhat.com> - 2015-09-28 22:20 +0200
Re: [PATCH 03/12] KVM: x86: Add a common TSC scaling function Haozhong Zhang <haozhong.zhang@intel.com> - 2015-09-29 04:00 +0200
[PATCH 10/12] KVM: VMX: Setup TSC scaling ratio when a vcpu is loaded Haozhong Zhang <haozhong.zhang@intel.com> - 2015-09-28 07:50 +0200
[PATCH 04/12] KVM: x86: Replace call-back set_tsc_khz() with a common function Haozhong Zhang <haozhong.zhang@intel.com> - 2015-09-28 07:50 +0200
Re: [PATCH 04/12] KVM: x86: Replace call-back set_tsc_khz() with a common function Haozhong Zhang <haozhong.zhang@intel.com> - 2015-09-29 05:50 +0200
Re: [PATCH 04/12] KVM: x86: Replace call-back set_tsc_khz() with a common function Radim Krčmář <rkrcmar@redhat.com> - 2015-10-05 22:00 +0200
Re: [PATCH 04/12] KVM: x86: Replace call-back set_tsc_khz() with a common function David Matlack <dmatlack@google.com> - 2015-10-05 22:50 +0200
Re: [PATCH 00/12] KVM: x86: add support for VMX TSC scaling Haozhong Zhang <haozhong.zhang@intel.com> - 2015-09-29 06:10 +0200
Re: [PATCH 00/12] KVM: x86: add support for VMX TSC scaling Eric Northup <digitaleric@google.com> - 2015-09-29 06:10 +0200
Page 2 of 2 — ← Prev page 1 [2]
| From | Radim Krčmář <rkrcmar@redhat.com> |
|---|---|
| Date | 2015-10-05 22:00 +0200 |
| Subject | Re: [PATCH 04/12] KVM: x86: Replace call-back set_tsc_khz() with a common function |
| Message-ID | <qgk5r-kd-1@gated-at.bofh.it> |
| In reply to | #1233863 |
2015-09-28 13:38+0800, Haozhong Zhang:
> Both VMX and SVM propagate virtual_tsc_khz in the same way, so this
> patch removes the call-back set_tsc_khz() and replaces it with a common
> function.
>
> Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
> ---
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> +static void set_tsc_khz(struct kvm_vcpu *vcpu, u32 user_tsc_khz, bool scale)
> +{
> + u64 ratio, khz;
| [...]
> + khz = user_tsc_khz;
I'd use "user_tsc_khz" directly.
> + /* TSC scaling required - calculate ratio */
> + shift = (kvm_tsc_scaling_ratio_frac_bits <= 32) ?
> + kvm_tsc_scaling_ratio_frac_bits : 32;
> + ratio = khz << shift;
> + do_div(ratio, tsc_khz);
> + ratio <<= (kvm_tsc_scaling_ratio_frac_bits - shift);
VMX is losing 16 bits by this operation; normal fixed point division
could get us a smaller drift (and an one-liner here) ...
at 4.3 GHz, 32 instead of 48 bits after decimal point translate to one
"lost" TSC tick per second, in the worst case.
Please mention that we are truncating on purpose :)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Matlack <dmatlack@google.com> |
|---|---|
| Date | 2015-10-05 22:50 +0200 |
| Subject | Re: [PATCH 04/12] KVM: x86: Replace call-back set_tsc_khz() with a common function |
| Message-ID | <qgkRQ-1x8-13@gated-at.bofh.it> |
| In reply to | #1239909 |
On Mon, Oct 5, 2015 at 12:53 PM, Radim Krčmář <rkrcmar@redhat.com> wrote:
> 2015-09-28 13:38+0800, Haozhong Zhang:
>> Both VMX and SVM propagate virtual_tsc_khz in the same way, so this
>> patch removes the call-back set_tsc_khz() and replaces it with a common
>> function.
>>
>> Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
>> ---
>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>> +static void set_tsc_khz(struct kvm_vcpu *vcpu, u32 user_tsc_khz, bool scale)
>> +{
>> + u64 ratio, khz;
> | [...]
>> + khz = user_tsc_khz;
>
> I'd use "user_tsc_khz" directly.
>
>> + /* TSC scaling required - calculate ratio */
>> + shift = (kvm_tsc_scaling_ratio_frac_bits <= 32) ?
>> + kvm_tsc_scaling_ratio_frac_bits : 32;
>> + ratio = khz << shift;
>> + do_div(ratio, tsc_khz);
>> + ratio <<= (kvm_tsc_scaling_ratio_frac_bits - shift);
>
> VMX is losing 16 bits by this operation; normal fixed point division
> could get us a smaller drift (and an one-liner here) ...
> at 4.3 GHz, 32 instead of 48 bits after decimal point translate to one
> "lost" TSC tick per second, in the worst case.
We can easily avoid losing precision on x86_64 (divq allows a 128-bit
dividend). 32-bit can just lose the 16 bits of precision (TSC scaling
is only available on SkyLake, and I'd be surprised if there were
many hosts running KVM in protected mode on SkyLake :)).
>
> Please mention that we are truncating on purpose :)
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Haozhong Zhang <haozhong.zhang@intel.com> |
|---|---|
| Date | 2015-09-29 06:10 +0200 |
| Message-ID | <qdUoO-3IA-3@gated-at.bofh.it> |
| In reply to | #1233849 |
On Mon, Sep 28, 2015 at 09:00:39PM -0700, Eric Northup wrote: > On Sun, Sep 27, 2015 at 10:37 PM, Haozhong Zhang > <haozhong.zhang@intel.com> 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 scaling 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. > > reviewed-by: Eric Northup <digitaleric@google.com> > Thank you for the review! > > > > 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 | 4 +- > > arch/x86/kvm/lapic.c | 5 +- > > arch/x86/kvm/svm.c | 113 +++-------------------------- > > arch/x86/kvm/vmx.c | 60 ++++++++-------- > > arch/x86/kvm/x86.c | 154 +++++++++++++++++++++++++++++++++++++--- > > include/linux/kvm_host.h | 21 +++++- > > 7 files changed, 221 insertions(+), 160 deletions(-) > > > > -- > > 2.4.8 > > > > -- > > To unsubscribe from this list: send the line "unsubscribe kvm" in > > the body of a message to majordomo@vger.kernel.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Eric Northup <digitaleric@google.com> |
|---|---|
| Date | 2015-09-29 06:10 +0200 |
| Message-ID | <qdUoO-3IA-5@gated-at.bofh.it> |
| In reply to | #1233849 |
On Sun, Sep 27, 2015 at 10:37 PM, Haozhong Zhang <haozhong.zhang@intel.com> 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 scaling 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. reviewed-by: Eric Northup <digitaleric@google.com> > > 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 | 4 +- > arch/x86/kvm/lapic.c | 5 +- > arch/x86/kvm/svm.c | 113 +++-------------------------- > arch/x86/kvm/vmx.c | 60 ++++++++-------- > arch/x86/kvm/x86.c | 154 +++++++++++++++++++++++++++++++++++++--- > include/linux/kvm_host.h | 21 +++++- > 7 files changed, 221 insertions(+), 160 deletions(-) > > -- > 2.4.8 > > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | linux.kernel
csiph-web