aboutsummaryrefslogtreecommitdiff
path: root/hw/vfio/pci.h
diff options
context:
space:
mode:
authorLongpeng(Mike) <longpeng2@huawei.com>2022-03-26 14:02:26 +0800
committerAlex Williamson <alex.williamson@redhat.com>2022-05-06 09:06:50 -0600
commitdc580d51f7dd3e02134957be2b771636ac59e868 (patch)
tree3a69f31376a9ef9ab3e32d2130d154876f9646a5 /hw/vfio/pci.h
parent75d546fc18023d36779c687b948128c1a4666a96 (diff)
downloadqemu-dc580d51f7dd3e02134957be2b771636ac59e868.zip
qemu-dc580d51f7dd3e02134957be2b771636ac59e868.tar.gz
qemu-dc580d51f7dd3e02134957be2b771636ac59e868.tar.bz2
vfio: defer to commit kvm irq routing when enable msi/msix
In migration resume phase, all unmasked msix vectors need to be setup when loading the VF state. However, the setup operation would take longer if the VM has more VFs and each VF has more unmasked vectors. The hot spot is kvm_irqchip_commit_routes, it'll scan and update all irqfds that are already assigned each invocation, so more vectors means need more time to process them. vfio_pci_load_config vfio_msix_enable msix_set_vector_notifiers for (vector = 0; vector < dev->msix_entries_nr; vector++) { vfio_msix_vector_do_use vfio_add_kvm_msi_virq kvm_irqchip_commit_routes <-- expensive } We can reduce the cost by only committing once outside the loop. The routes are cached in kvm_state, we commit them first and then bind irqfd for each vector. The test VM has 128 vcpus and 8 VF (each one has 65 vectors), we measure the cost of the vfio_msix_enable for each VF, and we can see 90+% costs can be reduce. VF Count of irqfds[*] Original With this patch 1st 65 8 2 2nd 130 15 2 3rd 195 22 2 4th 260 24 3 5th 325 36 2 6th 390 44 3 7th 455 51 3 8th 520 58 4 Total 258ms 21ms [*] Count of irqfds How many irqfds that already assigned and need to process in this round. The optimization can be applied to msi type too. Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com> Link: https://lore.kernel.org/r/20220326060226.1892-6-longpeng2@huawei.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'hw/vfio/pci.h')
-rw-r--r--hw/vfio/pci.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
index 6477751..7c236a5 100644
--- a/hw/vfio/pci.h
+++ b/hw/vfio/pci.h
@@ -19,6 +19,7 @@
#include "qemu/queue.h"
#include "qemu/timer.h"
#include "qom/object.h"
+#include "sysemu/kvm.h"
#define PCI_ANY_ID (~0)
@@ -171,6 +172,7 @@ struct VFIOPCIDevice {
bool no_kvm_ioeventfd;
bool no_vfio_ioeventfd;
bool enable_ramfb;
+ bool defer_kvm_irq_routing;
VFIODisplay *dpy;
Notifier irqchip_change_notifier;
};