mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
migration/postcopy: Replace QemuSemaphore with QemuEvent
thread_sync_sem is an one-shot event so it can be converted into QemuEvent, which is more lightweight. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Reviewed-by: Fabiano Rosas <farosas@suse.de> Link: https://lore.kernel.org/r/20250529-event-v5-9-53b285203794@daynix.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
da926a8b9d
commit
d401b7aed8
3 changed files with 8 additions and 8 deletions
|
@ -98,9 +98,9 @@ struct MigrationIncomingState {
|
||||||
void (*transport_cleanup)(void *data);
|
void (*transport_cleanup)(void *data);
|
||||||
/*
|
/*
|
||||||
* Used to sync thread creations. Note that we can't create threads in
|
* Used to sync thread creations. Note that we can't create threads in
|
||||||
* parallel with this sem.
|
* parallel with this event.
|
||||||
*/
|
*/
|
||||||
QemuSemaphore thread_sync_sem;
|
QemuEvent thread_sync_event;
|
||||||
/*
|
/*
|
||||||
* Free at the start of the main state load, set as the main thread finishes
|
* Free at the start of the main state load, set as the main thread finishes
|
||||||
* loading state.
|
* loading state.
|
||||||
|
|
|
@ -90,10 +90,10 @@ void postcopy_thread_create(MigrationIncomingState *mis,
|
||||||
QemuThread *thread, const char *name,
|
QemuThread *thread, const char *name,
|
||||||
void *(*fn)(void *), int joinable)
|
void *(*fn)(void *), int joinable)
|
||||||
{
|
{
|
||||||
qemu_sem_init(&mis->thread_sync_sem, 0);
|
qemu_event_init(&mis->thread_sync_event, false);
|
||||||
qemu_thread_create(thread, name, fn, mis, joinable);
|
qemu_thread_create(thread, name, fn, mis, joinable);
|
||||||
qemu_sem_wait(&mis->thread_sync_sem);
|
qemu_event_wait(&mis->thread_sync_event);
|
||||||
qemu_sem_destroy(&mis->thread_sync_sem);
|
qemu_event_destroy(&mis->thread_sync_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Postcopy needs to detect accesses to pages that haven't yet been copied
|
/* Postcopy needs to detect accesses to pages that haven't yet been copied
|
||||||
|
@ -964,7 +964,7 @@ static void *postcopy_ram_fault_thread(void *opaque)
|
||||||
trace_postcopy_ram_fault_thread_entry();
|
trace_postcopy_ram_fault_thread_entry();
|
||||||
rcu_register_thread();
|
rcu_register_thread();
|
||||||
mis->last_rb = NULL; /* last RAMBlock we sent part of */
|
mis->last_rb = NULL; /* last RAMBlock we sent part of */
|
||||||
qemu_sem_post(&mis->thread_sync_sem);
|
qemu_event_set(&mis->thread_sync_event);
|
||||||
|
|
||||||
struct pollfd *pfd;
|
struct pollfd *pfd;
|
||||||
size_t pfd_len = 2 + mis->postcopy_remote_fds->len;
|
size_t pfd_len = 2 + mis->postcopy_remote_fds->len;
|
||||||
|
@ -1716,7 +1716,7 @@ void *postcopy_preempt_thread(void *opaque)
|
||||||
|
|
||||||
rcu_register_thread();
|
rcu_register_thread();
|
||||||
|
|
||||||
qemu_sem_post(&mis->thread_sync_sem);
|
qemu_event_set(&mis->thread_sync_event);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The preempt channel is established in asynchronous way. Wait
|
* The preempt channel is established in asynchronous way. Wait
|
||||||
|
|
|
@ -2078,7 +2078,7 @@ static void *postcopy_ram_listen_thread(void *opaque)
|
||||||
|
|
||||||
migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
|
migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
|
||||||
MIGRATION_STATUS_POSTCOPY_ACTIVE);
|
MIGRATION_STATUS_POSTCOPY_ACTIVE);
|
||||||
qemu_sem_post(&mis->thread_sync_sem);
|
qemu_event_set(&mis->thread_sync_event);
|
||||||
trace_postcopy_ram_listen_thread_start();
|
trace_postcopy_ram_listen_thread_start();
|
||||||
|
|
||||||
rcu_register_thread();
|
rcu_register_thread();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue