Re: [PATCH 08/10] KVM: x86: Remove per-vCPU "cache" of its reference pvclock

From: Paul Durrant
Date: Tue Jan 21 2025 - 12:03:31 EST


On 18/01/2025 00:55, Sean Christopherson wrote:
Remove the per-vCPU "cache" of the reference pvclock and instead cache
only the TSC shift+multiplier. All other fields in pvclock are fully
recomputed by kvm_guest_time_update(), i.e. aren't actually persisted.

In addition to shaving a few bytes, explicitly tracking the TSC shift/mul
fields makes it easier to see that those fields are tied to hw_tsc_khz
(they exist to avoid having to do expensive math in the common case).
And conversely, not tracking the other fields makes it easier to see that
things like the version number are pulled from the guest's copy, not from
KVM's reference.

Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
---
arch/x86/include/asm/kvm_host.h | 3 ++-
arch/x86/kvm/x86.c | 27 +++++++++++++++------------
arch/x86/kvm/xen.c | 8 ++++----
3 files changed, 21 insertions(+), 17 deletions(-)


Reviewed-by: Paul Durrant <paul@xxxxxxx>