]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
KVM: x86: Avoid gratuitous global clock reload in kvm_arch_vcpu_load()
authorDavid Woodhouse <dwmw@amazon.co.uk>
Sun, 28 Apr 2024 12:59:49 +0000 (13:59 +0100)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Tue, 4 Jun 2024 10:31:47 +0000 (11:31 +0100)
Commit d98d07ca7e034 ("KVM: x86: update pvclock area conditionally, on
cpu migration") turned an unconditional KVM_REQ_CLOCK_UPDATE into a
conditional one, if either the master clock isn't enabled *or* the vCPU
was not previously scheduled (vcpu->cpu == -1). The commit message doesn't
explain the latter condition, which is specifically for the master clock
case.

Commit 0061d53daf26f ("KVM: x86: limit difference between kvmclock
updates") later turned that into a KVM_REQ_GLOBAL_CLOCK_UPDATE to avoid
skew between vCPUs.

In master clock mode there is no need for any of that, regardless of
whether/where this vCPU was previously scheduled.

Do it only if (!kvm->arch.use_master_clock).

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
arch/x86/kvm/x86.c

index 5be9f7cddcac2d3e011f38875fa187863d8fac8f..6913a6bd4126bec792a119588b4bfbe94f944d35 100644 (file)
@@ -5151,7 +5151,7 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
                 * On a host with synchronized TSC, there is no need to update
                 * kvmclock on vcpu->cpu migration
                 */
-               if (!vcpu->kvm->arch.use_master_clock || vcpu->cpu == -1)
+               if (!vcpu->kvm->arch.use_master_clock)
                        kvm_make_request(KVM_REQ_GLOBAL_CLOCK_UPDATE, vcpu);
                if (vcpu->cpu != cpu)
                        kvm_make_request(KVM_REQ_MIGRATE_TIMER, vcpu);