Re: [PATCH v4 1/2] KVM: X86: Less kvmclock sync induced vmexits after VM boots

From: Paolo Bonzini
Date: Tue Feb 18 2020 - 10:33:57 EST


On 18/02/20 15:54, Vitaly Kuznetsov wrote:
>> - schedule_delayed_work(&kvm->arch.kvmclock_sync_work,
>> - KVMCLOCK_SYNC_PERIOD);
>> + if (vcpu->vcpu_idx == 0)
>> + schedule_delayed_work(&kvm->arch.kvmclock_sync_work,
>> + KVMCLOCK_SYNC_PERIOD);
>> }
>>
>> void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu)
> Forgive me my ignorance, I was under the impression
> schedule_delayed_work() doesn't do anything if the work is already
> queued (see queue_delayed_work_on()) and we seem to be scheduling the
> same work (&kvm->arch.kvmclock_sync_work) which is per-kvm (not
> per-vcpu).

No, it executes after 5 minutes. I agree that the patch shouldn't be
really necessary, though you do save on cacheline bouncing due to
test_and_set_bit.

Paolo

> Do we actually happen to finish executing it before next vCPU
> is created or why does the storm you describe happens?