aboutsummaryrefslogtreecommitdiff
path: root/migration/migration.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2024-01-02 10:35:25 -0500
committerStefan Hajnoczi <stefanha@redhat.com>2024-01-08 10:45:43 -0500
commit195801d700c008b6a8d8acfa299aa5f177446647 (patch)
tree7ab423e4a773b818f6c6d65f2fa06dc4517cad24 /migration/migration.c
parent897a06c6d7ce8fb962a33cea1910d17218c746e9 (diff)
system/cpus: rename qemu_mutex_lock_iothread() to bql_lock()
The Big QEMU Lock (BQL) has many names and they are confusing. The actual QemuMutex variable is called qemu_global_mutex but it's commonly referred to as the BQL in discussions and some code comments. The locking APIs, however, are called qemu_mutex_lock_iothread() and qemu_mutex_unlock_iothread(). The "iothread" name is historic and comes from when the main thread was split into into KVM vcpu threads and the "iothread" (now called the main loop thread). I have contributed to the confusion myself by introducing a separate --object iothread, a separate concept unrelated to the BQL. The "iothread" name is no longer appropriate for the BQL. Rename the locking APIs to: - void bql_lock(void) - void bql_unlock(void) - bool bql_locked(void) There are more APIs with "iothread" in their names. Subsequent patches will rename them. There are also comments and documentation that will be updated in later patches. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Paul Durrant <paul@xen.org> Acked-by: Fabiano Rosas <farosas@suse.de> Acked-by: David Woodhouse <dwmw@amazon.co.uk> Reviewed-by: Cédric Le Goater <clg@kaod.org> Acked-by: Peter Xu <peterx@redhat.com> Acked-by: Eric Farman <farman@linux.ibm.com> Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com> Acked-by: Hyman Huang <yong.huang@smartx.com> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> Message-id: 20240102153529.486531-2-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'migration/migration.c')
-rw-r--r--migration/migration.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/migration/migration.c b/migration/migration.c
index 454cd4ec1f..be173cd0f9 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1283,12 +1283,12 @@ static void migrate_fd_cleanup(MigrationState *s)
QEMUFile *tmp;
trace_migrate_fd_cleanup();
- qemu_mutex_unlock_iothread();
+ bql_unlock();
if (s->migration_thread_running) {
qemu_thread_join(&s->thread);
s->migration_thread_running = false;
}
- qemu_mutex_lock_iothread();
+ bql_lock();
multifd_save_cleanup();
qemu_mutex_lock(&s->qemu_file_lock);
@@ -2396,7 +2396,7 @@ static int postcopy_start(MigrationState *ms, Error **errp)
}
trace_postcopy_start();
- qemu_mutex_lock_iothread();
+ bql_lock();
trace_postcopy_start_set_run();
migration_downtime_start(ms);
@@ -2504,7 +2504,7 @@ static int postcopy_start(MigrationState *ms, Error **errp)
migration_downtime_end(ms);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
if (migrate_postcopy_ram()) {
/*
@@ -2545,7 +2545,7 @@ fail:
error_report_err(local_err);
}
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return -1;
}
@@ -2579,14 +2579,14 @@ static int migration_maybe_pause(MigrationState *s,
* wait for the 'pause_sem' semaphore.
*/
if (s->state != MIGRATION_STATUS_CANCELLING) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
migrate_set_state(&s->state, *current_active_state,
MIGRATION_STATUS_PRE_SWITCHOVER);
qemu_sem_wait(&s->pause_sem);
migrate_set_state(&s->state, MIGRATION_STATUS_PRE_SWITCHOVER,
new_state);
*current_active_state = new_state;
- qemu_mutex_lock_iothread();
+ bql_lock();
}
return s->state == new_state ? 0 : -EINVAL;
@@ -2597,7 +2597,7 @@ static int migration_completion_precopy(MigrationState *s,
{
int ret;
- qemu_mutex_lock_iothread();
+ bql_lock();
migration_downtime_start(s);
s->vm_old_state = runstate_get();
@@ -2624,7 +2624,7 @@ static int migration_completion_precopy(MigrationState *s,
ret = qemu_savevm_state_complete_precopy(s->to_dst_file, false,
s->block_inactive);
out_unlock:
- qemu_mutex_unlock_iothread();
+ bql_unlock();
return ret;
}
@@ -2632,9 +2632,9 @@ static void migration_completion_postcopy(MigrationState *s)
{
trace_migration_completion_postcopy_end();
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_savevm_state_complete_postcopy(s->to_dst_file);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
/*
* Shutdown the postcopy fast path thread. This is only needed when dest
@@ -2658,14 +2658,14 @@ static void migration_completion_failed(MigrationState *s,
*/
Error *local_err = NULL;
- qemu_mutex_lock_iothread();
+ bql_lock();
bdrv_activate_all(&local_err);
if (local_err) {
error_report_err(local_err);
} else {
s->block_inactive = false;
}
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
migrate_set_state(&s->state, current_active_state,
@@ -3105,7 +3105,7 @@ static void migration_iteration_finish(MigrationState *s)
/* If we enabled cpu throttling for auto-converge, turn it off. */
cpu_throttle_stop();
- qemu_mutex_lock_iothread();
+ bql_lock();
switch (s->state) {
case MIGRATION_STATUS_COMPLETED:
migration_calculate_complete(s);
@@ -3136,7 +3136,7 @@ static void migration_iteration_finish(MigrationState *s)
break;
}
migrate_fd_cleanup_schedule(s);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
static void bg_migration_iteration_finish(MigrationState *s)
@@ -3148,7 +3148,7 @@ static void bg_migration_iteration_finish(MigrationState *s)
*/
ram_write_tracking_stop();
- qemu_mutex_lock_iothread();
+ bql_lock();
switch (s->state) {
case MIGRATION_STATUS_COMPLETED:
migration_calculate_complete(s);
@@ -3167,7 +3167,7 @@ static void bg_migration_iteration_finish(MigrationState *s)
}
migrate_fd_cleanup_schedule(s);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
/*
@@ -3289,9 +3289,9 @@ static void *migration_thread(void *opaque)
object_ref(OBJECT(s));
update_iteration_initial_status(s);
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_savevm_state_header(s->to_dst_file);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
/*
* If we opened the return path, we need to make sure dst has it
@@ -3319,9 +3319,9 @@ static void *migration_thread(void *opaque)
qemu_savevm_send_colo_enable(s->to_dst_file);
}
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_savevm_state_setup(s->to_dst_file);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
qemu_savevm_wait_unplug(s, MIGRATION_STATUS_SETUP,
MIGRATION_STATUS_ACTIVE);
@@ -3432,10 +3432,10 @@ static void *bg_migration_thread(void *opaque)
ram_write_tracking_prepare();
#endif
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_savevm_state_header(s->to_dst_file);
qemu_savevm_state_setup(s->to_dst_file);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
qemu_savevm_wait_unplug(s, MIGRATION_STATUS_SETUP,
MIGRATION_STATUS_ACTIVE);
@@ -3445,7 +3445,7 @@ static void *bg_migration_thread(void *opaque)
trace_migration_thread_setup_complete();
migration_downtime_start(s);
- qemu_mutex_lock_iothread();
+ bql_lock();
s->vm_old_state = runstate_get();
@@ -3483,7 +3483,7 @@ static void *bg_migration_thread(void *opaque)
s->vm_start_bh = qemu_bh_new(bg_migration_vm_start_bh, s);
qemu_bh_schedule(s->vm_start_bh);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
while (migration_is_active(s)) {
MigIterateState iter_state = bg_migration_iteration_run(s);
@@ -3512,7 +3512,7 @@ fail:
if (early_fail) {
migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE,
MIGRATION_STATUS_FAILED);
- qemu_mutex_unlock_iothread();
+ bql_unlock();
}
bg_migration_iteration_finish(s);