On 16/06/20 01:07, Jim Mattson wrote: > + } else if (vcpu->arch.this_tsc_generation != > + kvm->arch.cur_tsc_generation) { > u64 tsc_exp = kvm->arch.last_tsc_write + > nsec_to_cycles(vcpu, elapsed); > u64 tsc_hz = vcpu->arch.virtual_tsc_khz * 1000LL; Can this cause the same vCPU to be counted multiple times in nr_vcpus_matched_tsc? I think you need to keep already_matched (see also the commit message for 0d3da0d26e3c, "KVM: x86: fix TSC matching", 2014-07-09, which introduced that variable). Thanks, Paolo > @@ -2062,7 +2062,6 @@ void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr) > offset = kvm_compute_tsc_offset(vcpu, data); > } > matched = true; > - already_matched = (vcpu->arch.this_tsc_generation == kvm->arch.cur_tsc_generation); > } else { > /* > * We split periods of matched TSC writes into generations. > @@ -2102,12 +2101,10 @@ void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr) > raw_spin_unlock_irqrestore(&kvm->arch.tsc_write_lock, flags); > > spin_lock(&kvm->arch.pvclock_gtod_sync_lock); > - if (!matched) { > - kvm->arch.nr_vcpus_matched_tsc = 0; > - } else if (!already_matched) { > + if (matched) > kvm->arch.nr_vcpus_matched_tsc++; > - } > - > + else > + kvm->arch.nr_vcpus_matched_tsc = 0;