On 27.08.2025 22:59, Peter Xu wrote:
We may switch to a BQL-free loadvm model.  Be prepared with it.

Cc: Cédric Le Goater <c...@redhat.com>
Cc: Maciej S. Szmigiero <m...@maciej.szmigiero.name>
Signed-off-by: Peter Xu <pet...@redhat.com>
---
  hw/vfio/migration-multifd.c | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/hw/vfio/migration-multifd.c b/hw/vfio/migration-multifd.c
index e4785031a7..8dc8444f0d 100644
--- a/hw/vfio/migration-multifd.c
+++ b/hw/vfio/migration-multifd.c
@@ -763,16 +763,21 @@ int vfio_multifd_switchover_start(VFIODevice *vbasedev)
  {
      VFIOMigration *migration = vbasedev->migration;
      VFIOMultifd *multifd = migration->multifd;
+    bool bql_is_locked = bql_locked();
assert(multifd); /* The lock order is load_bufs_mutex -> BQL so unlock BQL here first */
-    bql_unlock();
+    if (bql_is_locked) {
+        bql_unlock();
+    }
      WITH_QEMU_LOCK_GUARD(&multifd->load_bufs_mutex) {
          assert(!multifd->load_bufs_thread_running);
          multifd->load_bufs_thread_running = true;
      }
-    bql_lock();
+    if (bql_is_locked) {
+        bql_lock();
+    }
qemu_loadvm_start_load_thread(vfio_load_bufs_thread, vbasedev);

This patch makes sense to me - I don't see anything obviously wrong here.

In general, thank you for your series Peter.

I am actually looking at a similar subject - how to make
vfio_pci_load_config() and its sub-calls use more fine grained locking
than BQL so device configuration loading for multiple VFIO devices
can happen in parallel instead of being serialized by BQL.

Don't have an ETA for this yet, but it's good that other people also
working on improving live migration scalability.

Thanks,
Maciej


Reply via email to