Re: [PATCH v4 13/17] kvm: i8254: Deactivate APICv when using in-kernel PIT re-injection mode.
From: Suravee Suthikulpanit
Date: Mon Nov 11 2019 - 12:38:31 EST
Roman/Paolo
On 11/5/2019 4:47 PM, Paolo Bonzini wrote:
On 05/11/19 00:17, Roman Kagan wrote:
This is not too nice for Intel which does support (through the EOI exit
mask) APICv even if PIT reinjection active.
Hmm, it's tempting to just make svm_load_eoi_exitmap() disable AVIC when
given a non-empty eoi_exit_bitmap, and enable it back on a clear
eoi_exit_bitmap. This may remove the need to add special treatment to
PIT etc.
That is a very nice idea---we can make that a single disable reason,
like APICV_DEACTIVATE_REASON_EOI, and Intel can simply never use it.
I took at look at the svm_load_eoi_exitmap() and it is called via:
kvm_make_scan_ioapic_request() ->
KVM_REQ_SCAN_IOAPIC -> vcpu_scan_ioapic() ->
KVM_REQ_LOAD_EOI_EXITMAP -> vcpu_load_eoi_exitmap()
The kvm_make_scan_ioapic_request() is called from multiple places:
arch/x86/kvm/irq_comm.c:
* kvm_arch_post_irq_routing_update() : Called from kvm_set_irq_routing()
arch/x86/kvm/ioapic.c:
* kvm_arch_post_irq_ack_notifier_list_update() : (Un)registering irq ack notifier
* kvm_set_ioapic() : Setting ioapic irqchip
* ioapic_mmio_write() -> ioapic_write_indirect()
arch/x86/kvm/lapic.c:
* recalculate_apic_map()
Most calls would be from ioapic_mmio_write()->ioapic_write_indirect().
In case of AMD AVIC, the svm_load_e::vsoi_exitmap() is called several times, and requesting
APICV (de)activate from here when the eoi_exit_bitmap is set/clear would introduce
large overhead especially with SMP machine. So, for now, let's just disable APICv
when in-kernel PIT is in reinject (delay) mode.
I'll also add the logic to avoid unnecessary overhead for Intel.
Thanks,
Suravee