[PATCH 13/13] migration/vfio: Drop BQL dependency for loadvm SWITCHOVER_START

Peter Xu posted 13 patches 3 weeks, 1 day ago
Maintainers: Alex Williamson <alex@shazbot.org>, "Cédric Le Goater" <clg@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Hailiang Zhang <zhanghailiang@xfusion.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Li Zhijian <lizhijian@fujitsu.com>
[PATCH 13/13] migration/vfio: Drop BQL dependency for loadvm SWITCHOVER_START
Posted by Peter Xu 3 weeks, 1 day ago
That was there only because we used to do loadvm in a coroutine on the main
thread with BQL held, while there was a locking order issue.

Now make the API to not depend on BQL anymore.  Instead making sure we
don't take BQL invoking switchover_start() hooks.

Cc: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Cc: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 hw/vfio/migration-multifd.c | 3 ---
 migration/savevm.c          | 3 +--
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/hw/vfio/migration-multifd.c b/hw/vfio/migration-multifd.c
index e4785031a7..c824f30fb0 100644
--- a/hw/vfio/migration-multifd.c
+++ b/hw/vfio/migration-multifd.c
@@ -766,13 +766,10 @@ int vfio_multifd_switchover_start(VFIODevice *vbasedev)
 
     assert(multifd);
 
-    /* The lock order is load_bufs_mutex -> BQL so unlock BQL here first */
-    bql_unlock();
     WITH_QEMU_LOCK_GUARD(&multifd->load_bufs_mutex) {
         assert(!multifd->load_bufs_thread_running);
         multifd->load_bufs_thread_running = true;
     }
-    bql_lock();
 
     qemu_loadvm_start_load_thread(vfio_load_bufs_thread, vbasedev);
 
diff --git a/migration/savevm.c b/migration/savevm.c
index 16fae635c0..f67b97c9ab 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2648,8 +2648,7 @@ static int loadvm_process_command(QEMUFile *f, bool bql_held, Error **errp)
         return loadvm_process_enable_colo(mis, errp);
 
     case MIG_CMD_SWITCHOVER_START:
-        WITH_BQL_HELD(bql_held) {
-            /* TODO: drop the BQL dependency */
+        WITH_BQL_RELEASED(bql_held) {
             ret = loadvm_postcopy_handle_switchover_start(errp);
         }
         return ret;
-- 
2.50.1