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

Maciej S. Szmigiero posted 13 patches 1 month ago
Failed in applying to current master (apply log)
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(-)
[PATCH v2 00/13] VFIO device migration parallel state transitions
Posted by Maciej S. Szmigiero 1 month ago
From: "Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>

This is an updated v2 patch series of the v1 series located at:
https://lore.kernel.org/qemu-devel/cover.1779217494.git.maciej.szmigiero@oracle.com/
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/al42_qzCLAjE-Mch@x1.local/


  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(-)