Re: [KVM TSC trapping / migration 1/2] Add TSC trapping for SVM andVMX

From: Zachary Amsden
Date: Thu Jan 06 2011 - 15:03:58 EST

On 01/06/2011 01:32 AM, Avi Kivity wrote:
On 01/06/2011 12:10 PM, Zachary Amsden wrote:
Reasons to trap the TSC are numerous, but we want to avoid it as much
as possible for performance reasons.

We provide two conservative modes via modules parameters and userspace
hinting. First, the module can be loaded with "tsc_auto=1" as a module
parameter, which turns on conservative TSC trapping only when it is
required (when unstable TSC or faster KHZ CPU is detected).

For userspace hinting, we enable trapping only if necessary. Userspace
can hint that a VM needs a fixed frequency TSC, and also that SMP
stability will be required. In that case, we conservatively turn on
trapping when it is needed. In addition, users may now specify the
desired TSC rate at which to run. If this rate differs significantly
from the host rate, trapping will be enabled.

There is also an override control to allow TSC trapping to be turned on
or off unconditionally for testing.

We indicate to pvclock users that the TSC is being trapped, to allow
avoiding overhead and directly using RDTSCP (only for SVM). This
optimization is not yet implemented.

Signed-off-by: Zachary Amsden<zamsden@xxxxxxxxxx>
arch/x86/include/asm/kvm_host.h | 6 +-
arch/x86/include/asm/pvclock-abi.h | 1 +
arch/x86/kvm/svm.c | 20 ++++++
arch/x86/kvm/vmx.c | 21 +++++++
arch/x86/kvm/x86.c | 113 +++++++++++++++++++++++++++++++++---
arch/x86/kvm/x86.h | 2 +
include/linux/kvm.h | 15 +++++
7 files changed, 168 insertions(+), 10 deletions(-)

Haven't reviewed yet, but Documentation/kvm/api.txt is missing here.

That will be included when I port to upstream head. When dealing with software documentation, too much is never enough.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at