Skip to content

Commit 202470d

Browse files
sean-jcbonzini
authored andcommitted
KVM: SVM: Don't bother checking for "running" AVIC when kicking for IPIs
Drop the avic_vcpu_is_running() check when waking vCPUs in response to a VM-Exit due to incomplete IPI delivery. The check isn't wrong per se, but it's not 100% accurate in the sense that it doesn't guarantee that the vCPU was one of the vCPUs that didn't receive the IPI. The check isn't required for correctness as blocking == !running in this context. From a performance perspective, waking a live task is not expensive as the only moderately costly operation is a locked operation to temporarily disable preemption. And if that is indeed a performance issue, kvm_vcpu_is_blocking() would be a better check than poking into the AVIC. Signed-off-by: Sean Christopherson <[email protected]> Reviewed-by: Maxim Levitsky <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 31f251d commit 202470d

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

arch/x86/kvm/svm/avic.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,16 @@ static void avic_kick_target_vcpus(struct kvm *kvm, struct kvm_lapic *source,
295295
struct kvm_vcpu *vcpu;
296296
unsigned long i;
297297

298+
/*
299+
* Wake any target vCPUs that are blocking, i.e. waiting for a wake
300+
* event. There's no need to signal doorbells, as hardware has handled
301+
* vCPUs that were in guest at the time of the IPI, and vCPUs that have
302+
* since entered the guest will have processed pending IRQs at VMRUN.
303+
*/
298304
kvm_for_each_vcpu(i, vcpu, kvm) {
299-
bool m = kvm_apic_match_dest(vcpu, source,
300-
icrl & APIC_SHORT_MASK,
301-
GET_APIC_DEST_FIELD(icrh),
302-
icrl & APIC_DEST_MASK);
303-
304-
if (m && !avic_vcpu_is_running(vcpu))
305+
if (kvm_apic_match_dest(vcpu, source, icrl & APIC_SHORT_MASK,
306+
GET_APIC_DEST_FIELD(icrh),
307+
icrl & APIC_DEST_MASK))
305308
kvm_vcpu_wake_up(vcpu);
306309
}
307310
}

arch/x86/kvm/svm/svm.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -573,17 +573,6 @@ extern struct kvm_x86_nested_ops svm_nested_ops;
573573

574574
#define VMCB_AVIC_APIC_BAR_MASK 0xFFFFFFFFFF000ULL
575575

576-
static inline bool avic_vcpu_is_running(struct kvm_vcpu *vcpu)
577-
{
578-
struct vcpu_svm *svm = to_svm(vcpu);
579-
u64 *entry = svm->avic_physical_id_cache;
580-
581-
if (!entry)
582-
return false;
583-
584-
return (READ_ONCE(*entry) & AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK);
585-
}
586-
587576
int avic_ga_log_notifier(u32 ga_tag);
588577
void avic_vm_destroy(struct kvm *kvm);
589578
int avic_vm_init(struct kvm *kvm);

0 commit comments

Comments
 (0)