Re: [PATCH v3] KVM: x86/vmx: Suppress posted interrupt notification when CPU is in host

From: Chao Gao
Date: Thu Sep 29 2022 - 01:59:30 EST


On Wed, Sep 28, 2022 at 07:16:03PM +0800, Chao Gao wrote:
>@@ -10538,6 +10547,17 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
>
> vcpu->mode = OUTSIDE_GUEST_MODE;
> smp_wmb();
>+ /*
>+ * Suppress notification when CPU is OUTSIDE_GUEST_MODE to avoid
>+ * wasting time on handling interrupts. A notification to host/kvm
>+ * just indicates some interrupts are posted for a vCPU. Since KVM
>+ * always syncs pending interrupts in PIR to vAPIC IRR before guest
>+ * entry (in ->sync_pir_to_irr()), notification isn't needed.
>+ *
>+ * Do this even if apicv is disabled for simplicity.
>+ */
>+ if (kvm_lapic_enabled(vcpu))
>+ static_call_cond(kvm_x86_pi_suppress_notification)(vcpu, true);

I missed the other kvm's setting vcpu->mode to OUTSIDE_GUEST_MODE in
this function (a few lines above). Will fix it in v4.

>
> /*
> * Sync xfd before calling handle_exit_irqoff() which may
>
>base-commit: 372d07084593dc7a399bf9bee815711b1fb1bcf2
>--
>2.25.1
>