Skip to content

VFIO device migration parallel state transitions

Maciej S. Szmigiero qemu-arm qemu-devel 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest13 patches 0 repliesNew
  2. v12 patches 23 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13runstate: Rename VM change state handlers "priority" to "depth"include/system/runstate.h system/runstate.c+13 -130 replies
2/13runstate: Introduce VM change state handlers explicit priority levelshw/core/vm-change-state-handler.c hw/vfio/migration.c hw/vfio/vfio-migration-internal.h +2 more+98 -770 replies
3/13runstate: Add an intermediate VM change state handlers SYNC priorityinclude/system/runstate.h system/runstate.c+4 -10 replies
4/13hw/vfio: Introduce VFIOPCIDeviceClasshw/vfio/pci.c hw/vfio/pci.h+6 -10 replies
5/13vfio/migration: Parallelize device state transitionshw/vfio/migration.c hw/vfio/pci.c hw/vfio/pci.h +3 more+237 -60 replies
6/13spapr/xive: Split VM state change handler into start and stop partshw/intc/spapr_xive_kvm.c+48 -260 replies
7/13runstate: Start/stop interrupt controllers before/after ordinary deviceshw/i386/vapic.c hw/intc/arm_gicv3_its_kvm.c hw/intc/arm_gicv3_kvm.c +4 more+33 -220 replies
8/13audio: Split VM state change handler into start and stop partsaudio/audio-mixeng-be.c audio/audio_int.h+36 -90 replies
9/13audio: Make sure to stop audio before VFIO gets non-DMA-capableaudio/audio-mixeng-be.c tests/audio/audio-stubs.c+9 -20 replies
10/13net: Split VM state change handler into start and stop partsnet/net.c+36 -160 replies
11/13net: Make sure to stop net before VFIO gets non-DMA-capablenet/net.c+2 -20 replies
12/13virtio: Split VM state change handler into start and stop partshw/virtio/virtio.c include/hw/virtio/virtio.h+29 -60 replies
13/13virtio: Make sure to stop virtio before VFIO gets non-DMA-capablehw/virtio/virtio.c+2 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 00/13] VFIO device migration parallel state transitions

From: "Maciej S. Szmigiero" <[email protected]>

This is an updated v2 patch series of the v1 series located at:
https://lore.kernel.org/qemu-devel/[email protected]/
v1 also contains detailed description and benchmarks of downtime performance improvements brought by this parallelization.

The main change in v2 is that the VFIO parallel state changing threads are implemented/managed differently.

Specifically, a design based on one that Peter has suggested during the review of v1 in [1] was implemented:
* The "priority" of existing VM change state handlers is renamed "depth",

* The now-freed "priority" term is used to implement an explicit, three-level VM_CHANGE_STATE_PRI_* priority system:
NORMAL priority is the old cb(), HIGH priority is the old prepare_cb(), while a new SYNC priority level is introduced between them.

* Devices that can produce DMA have their VM stop handlers to HIGH level to stop them before VFIO devices start reaching states not capable of accepting incoming DMA.
This affected virtio, net and audio VM state change handlers.

* Interrupt controllers have their handlers moved so they are started before VFIO devices at VM_CHANGE_STATE_PRI_HIGH on VM start and stopped only after VFIO devices at VM_CHANGE_STATE_PRI_NORMAL.
To further reinforce this ordering and make sure that it isn't lost in some future code refactor, an explicit VMChangeStateHandlerDepth system for these controllers is introduced - much like migration already had explicit MigrationPriority values for them.

* The VFIO device state changing threads are now launched and joined just once during VM start or VM stop sequence, instead of having been launched and joined per each transition.

* The priority/qdev depth adjustment mechanism from v1 and an extra layer of indirection for VFIO VM change state handlers are no longer required - so were removed.

Note: the PPC and ARM changes are compile-tested only. However, they are almost trivial so no significant risk is expected from that.

[1]: https://lore.kernel.org/qemu-devel/[email protected]/

runstate: Rename VM change state handlers "priority" to "depth"
runstate: Introduce VM change state handlers explicit priority levels
runstate: Add an intermediate VM change state handlers SYNC priority hw/vfio: Introduce VFIOPCIDeviceClass
vfio/migration: Parallelize device state transitions spapr/xive: Split VM state change handler into start and stop parts
runstate: Start/stop interrupt controllers before/after ordinary
devices
audio: Split VM state change handler into start and stop parts
audio: Make sure to stop audio before VFIO gets non-DMA-capable
net: Split VM state change handler into start and stop parts
net: Make sure to stop net before VFIO gets non-DMA-capable
virtio: Split VM state change handler into start and stop parts
virtio: Make sure to stop virtio before VFIO gets non-DMA-capable

 audio/audio-mixeng-be.c           |  42 ++++--
 audio/audio_int.h                 |   3 +-
 hw/core/vm-change-state-handler.c |  16 ++-
 hw/i386/vapic.c                   |   5 +-
 hw/intc/arm_gicv3_its_kvm.c       |   4 +-
 hw/intc/arm_gicv3_kvm.c           |   4 +-
 hw/intc/spapr_xive_kvm.c          |  80 ++++++-----
 hw/vfio/migration.c               | 230 +++++++++++++++++++++++++++++-
 hw/vfio/pci.c                     |   7 +
 hw/vfio/pci.h                     |  10 +-
 hw/vfio/trace-events              |   2 +
 hw/vfio/vfio-migration-internal.h |   3 +
 hw/virtio/virtio.c                |  32 ++++-
 include/hw/ppc/spapr_xive.h       |   3 +-
 include/hw/vfio/vfio-device.h     |   1 +
 include/hw/virtio/virtio.h        |   3 +-
 include/system/runstate.h         |  55 ++++---
 net/net.c                         |  52 ++++---
 system/runstate.c                 | 115 ++++++++-------
 tests/audio/audio-stubs.c         |   7 +
 20 files changed, 522 insertions(+), 152 deletions(-)