Re: [RFC PATCH] x86, kvm: use kvmclock to compute TSC deadline value
From: Paolo Bonzini
Date: Fri Jul 08 2016 - 17:44:30 EST
> > Luckily tsc_khz is really used by very little
> > outside the tsc clocksource (which kvmclock replaces) and the TSC
> > deadline timer.
>
> Two other ways to solve the problem, I don't know if you've considered:
> * Constrain the set of hosts a given VM can run on based on the TSC
> rate. (So don't need a perfectly homogenous fleet, just need each VM
> to be constrained to a homogenous subset).
True.
> * Disable the TSC deadline timer from QEMU by assigning a CPUID with
> the TSC capability zeroed (at least among VMs which could migrate to
> hosts with different TSC rates). These VMs will use the APIC timer
> which runs at a nice fixed rate.
Yes, this is the trivial workaround, but given the nice speedup from
the TSC deadline timer I didn't consider it.
To solve the migration problem I'm thinking of using the kvmclock MSR.
For example, if a bit is set in the kvmclock MSR then userspace should
convert the TSC deadline MSR to nanoseconds on migration and back to TSC
units on the destination. In other words, it says that the guest is
okay with the TSC deadline MSR changing under its feet when live
migration happens. But there may be other solutions.
Paolo