On 3/18/22 19:39, Oliver Upton wrote:
Hi Paolo,
On Wed, Mar 16, 2022 at 08:47:59AM +0100, Paolo Bonzini wrote:
On 3/16/22 05:53, Oliver Upton wrote:
The VMM has control of both the guest's TSC scale and offset. Extend the
described migration algorithm in the KVM_VCPU_TSC_OFFSET documentation
to cover TSC scaling.
Reported-by: David Woodhouse<dwmw@xxxxxxxxxxxx>
Signed-off-by: Oliver Upton<oupton@xxxxxxxxxx>
---
Applies to kvm/queue (references KVM_{GET,SET}_TSC_KHZ on a VM fd).
A few more things that have to be changed:
1. Invoke the KVM_GET_CLOCK ioctl to record the host TSC (tsc_src),
kvmclock nanoseconds (guest_src), and host CLOCK_REALTIME nanoseconds
(host_src).
One of two changes:
a) Add "Multiply tsc_src by guest_freq / src_freq to obtain scaled_tsc_src",
add a new device attribute for the host TSC frequency.
b) Add "Multiply tsc_src by src_ratio to obtain scaled_tsc_src", add a new
device attribute for the guest_frequency/host_frequency ratio.
A third would be scaling the host TSC frequency in KVM_GETCLOCK, but that's
confusing IMO.
Agreed -- I think kvmclock should remain as is.
A fourth would be to expose the host's TSC frequency outside of KVM
since we're really in the business of guest features, not host ones :-)
We already have a patch that does this internally, and its visible in
some of our open source userspace libraries [1].
Yeah, it was a bit of a cop out on my part but adding it to sysfs would
be nice. Please tell me if any of you going to send a patch, or even
just share it so that I can handle the upstream submission.
Paolo
That said, I do not have any immediate reservations about adding an
attribute as the easy way out.
Ack on the rest of the feedback, I'll touch up the documentation further
once we figure out TSC frequency exposure.
[1]: https://github.com/abseil/abseil-cpp/blob/c33f21f86a14216336b87d48e9b552a13985b2bc/absl/base/internal/sysinfo.cc#L311
--
Thanks,
Oliver