Re: [PATCH v4 04/17] kvm: x86: Add support for activate/de-activate APICv at runtime

From: Suthikulpanit, Suravee
Date: Mon Nov 04 2019 - 14:22:49 EST


Paolo,

On 11/2/19 4:52 AM, Paolo Bonzini wrote:
> On 01/11/19 23:41, Suthikulpanit, Suravee wrote:
>> +void kvm_request_apicv_update(struct kvm *kvm, bool activate, ulong bit)
>> +{
>> + if (activate) {
>> + if (!test_and_clear_bit(bit, &kvm->arch.apicv_deact_msk) ||
>> + !kvm_apicv_activated(kvm))
>> + return;
>> + } else {
>> + if (test_and_set_bit(bit, &kvm->arch.apicv_deact_msk) ||
>> + kvm_apicv_activated(kvm))
>> + return;
>> + }
>> +
>> + kvm_make_all_cpus_request(kvm, KVM_REQ_APICV_UPDATE);
>> +}
>> +EXPORT_SYMBOL_GPL(kvm_request_apicv_update);
>> +
>
> It's worth documenting the locking requirements of
> kvm_request_apicv_update (it can also be negative requirements, such as
> "don't hold any lock"), because kvm_make_all_cpus_request is a somewhat
> deadlock-prone API.

Currently, I have a comment in the svm_request_update_avic(), where it
calls kvm_request_apicv_update. I'll move it here instead and enhance
the comment.

Thanks,
Suravee