Re: [PATCH v4 09/11] KVM: X86: Add vendor callbacks for writing the TSC multiplier

From: Paolo Bonzini
Date: Thu May 27 2021 - 09:08:24 EST


On 27/05/21 10:33, Stamatis, Ilias wrote:
#ifdef CONFIG_X86_64
@@ -10444,6 +10461,7 @@ void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)
return;
vcpu_load(vcpu);
kvm_synchronize_tsc(vcpu, 0);
+ kvm_vcpu_write_tsc_multiplier(vcpu, kvm_default_tsc_scaling_ratio);
Hmm, I'm actually thinking now that this might not be correct. For example in
case we hotplug a new vCPU but the other vCPUs don't use the default ratio.

It is correct, the TSC frequency can be set per CPU (which is useless except possibly for debugging OS timekeeping, but still). So, the default kHz after hotplug is the host frequency.

It doesn't really matter because it only affects the fixed delta between the hotplugged CPU and the others as soon as userspace sets the frequency to the correct value.

Paolo