]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit - arch/x86/kvm/vmx.c
KVM: Infrastructure for software and hardware based TSC rate scaling
authorZachary Amsden <zamsden@gmail.com>
Fri, 3 Feb 2012 17:43:50 +0000 (15:43 -0200)
committerAvi Kivity <avi@redhat.com>
Thu, 8 Mar 2012 12:09:35 +0000 (14:09 +0200)
commitcc578287e3224d0da196cc1d226bdae6b068faa7
treec4352ebbd4d35de296622a8be99d76a1a6a48793
parenta59cb29e4d81e025192550c2703f305637f016f6
KVM: Infrastructure for software and hardware based TSC rate scaling

This requires some restructuring; rather than use 'virtual_tsc_khz'
to indicate whether hardware rate scaling is in effect, we consider
each VCPU to always have a virtual TSC rate.  Instead, there is new
logic above the vendor-specific hardware scaling that decides whether
it is even necessary to use and updates all rate variables used by
common code.  This means we can simply query the virtual rate at
any point, which is needed for software rate scaling.

There is also now a threshold added to the TSC rate scaling; minor
differences and variations of measured TSC rate can accidentally
provoke rate scaling to be used when it is not needed.  Instead,
we have a tolerance variable called tsc_tolerance_ppm, which is
the maximum variation from user requested rate at which scaling
will be used.  The default is 250ppm, which is the half the
threshold for NTP adjustment, allowing for some hardware variation.

In the event that hardware rate scaling is not available, we can
kludge a bit by forcing TSC catchup to turn on when a faster than
hardware speed has been requested, but there is nothing available
yet for the reverse case; this requires a trap and emulate software
implementation for RDTSC, which is still forthcoming.

[avi: fix 64-bit division on i386]

Signed-off-by: Zachary Amsden <zamsden@gmail.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/lapic.c
arch/x86/kvm/svm.c
arch/x86/kvm/vmx.c
arch/x86/kvm/x86.c