qemu-e2k/hw
Longpeng(Mike) dc580d51f7 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>
2022-05-06 09:06:50 -06:00
..
9pfs 9pfs: fix qemu_mknodat() to always return -1 on error on macOS host 2022-05-01 14:07:03 +02:00
acpi
adc aspeed/adc: Add AST1030 support 2022-05-02 17:03:02 +02:00
alpha
arm target/arm: Replace sentinels with ARRAY_SIZE in cpregs.h 2022-05-05 09:35:50 +01:00
audio
avr
block
char hw/char: fix qcode array bounds check in ESCC impl 2022-04-26 16:12:26 +01:00
core hw/core: Move the ARM sysbus-fdt to core 2022-04-29 10:48:26 +10:00
cpu
cris
display hw/display/vmware_vga: do not discard screen updates 2022-04-22 11:47:08 +02:00
dma
gpio hw/gpio/aspeed_gpio: Fix QOM pin property 2022-05-02 17:03:04 +02:00
hppa
hyperv util: rename qemu_*block() socket functions 2022-05-03 15:53:20 +04:00
i2c
i386 i386: firmware parsing and sev setup for -bios loaded firmware 2022-04-27 07:51:01 +02:00
ide
input hw: replace qemu_set_nonblock() 2022-05-03 15:52:33 +04:00
intc ppc/xive: Update the state of the External interrupt signal 2022-05-05 15:36:17 -03:00
ipack
ipmi
isa
m68k
mem
microblaze
mips
misc Misc cleanups 2022-05-03 09:13:17 -07:00
net
nios2 hw/nios2: Machine with a Vectored Interrupt Controller 2022-04-26 08:17:05 -07:00
nubus
nvme
nvram
openrisc
pci
pci-bridge
pci-host
pcmcia
ppc target/ppc: Remove msr_pr macro 2022-05-05 15:36:17 -03:00
rdma hw/pvrdma: Some cosmetic fixes 2022-04-26 12:25:14 +02:00
remote
riscv hw/riscv: Enable TPM backends 2022-04-29 10:48:48 +10:00
rtc
rx hw/rx: rx-gdbsim DTB load address aligned of 16byte. 2022-04-21 10:06:42 -07:00
s390x target/s390x: add S390_FEAT_VECTOR_ENH2 to qemu CPU model 2022-05-04 08:47:19 +02:00
scsi
sd
sensor
sh4
smbios
sparc
sparc64
ssi aspeed/smc: Add AST1030 support 2022-05-02 17:03:03 +02:00
timer aspeed/timer: Add AST1030 support 2022-05-02 17:03:03 +02:00
tpm
tricore
usb
vfio vfio: defer to commit kvm irq routing when enable msi/msix 2022-05-06 09:06:50 -06:00
virtio vhost-user: Use correct macro name TARGET_PPC64 2022-05-05 15:36:16 -03:00
watchdog aspeed/wdt: Add AST1030 support 2022-05-02 17:03:03 +02:00
xen meson: remove CONFIG_XEN_PCI_PASSTHROUGH from config-target.h 2022-04-28 08:52:22 +02:00
xenpv
xtensa
Kconfig
meson.build