[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 8/8] migration/postcopy: Replace QemuSemaphore with QemuEvent
From: |
Akihiko Odaki |
Subject: |
[PATCH 8/8] migration/postcopy: Replace QemuSemaphore with QemuEvent |
Date: |
Wed, 25 Dec 2024 14:44:20 +0900 |
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>
---
migration/migration.h | 4 ++--
migration/postcopy-ram.c | 10 +++++-----
migration/savevm.c | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/migration/migration.h b/migration/migration.h
index 14032e347ece..405f69c095e4 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -97,9 +97,9 @@ struct MigrationIncomingState {
void (*transport_cleanup)(void *data);
/*
* 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
* loading state.
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index a535fd2e30c9..80f780bff87c 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -90,10 +90,10 @@ void postcopy_thread_create(MigrationIncomingState *mis,
QemuThread *thread, const char *name,
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_sem_wait(&mis->thread_sync_sem);
- qemu_sem_destroy(&mis->thread_sync_sem);
+ qemu_event_wait(&mis->thread_sync_event);
+ qemu_event_destroy(&mis->thread_sync_event);
}
/* 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();
rcu_register_thread();
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;
size_t pfd_len = 2 + mis->postcopy_remote_fds->len;
@@ -1716,7 +1716,7 @@ void *postcopy_preempt_thread(void *opaque)
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
diff --git a/migration/savevm.c b/migration/savevm.c
index f4e4876f7202..03e4cb63f35b 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1987,7 +1987,7 @@ static void *postcopy_ram_listen_thread(void *opaque)
migrate_set_state(&mis->state, MIGRATION_STATUS_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();
rcu_register_thread();
--
2.47.1
- [PATCH 0/8] Improve futex usage, Akihiko Odaki, 2024/12/25
- [PATCH 1/8] futex: Check value after qemu_futex_wait(), Akihiko Odaki, 2024/12/25
- [PATCH 2/8] futex: Support Windows, Akihiko Odaki, 2024/12/25
- [PATCH 3/8] qemu-thread: Avoid futex abstraction for non-Linux, Akihiko Odaki, 2024/12/25
- [PATCH 4/8] qemu-thread: Use futex for QemuEvent on Windows, Akihiko Odaki, 2024/12/25
- [PATCH 5/8] qemu-thread: Use futex if available for QemuLockCnt, Akihiko Odaki, 2024/12/25
- [PATCH 6/8] migration: Replace QemuSemaphore with QemuEvent, Akihiko Odaki, 2024/12/25
- [PATCH 7/8] migration/colo: Replace QemuSemaphore with QemuEvent, Akihiko Odaki, 2024/12/25
- [PATCH 8/8] migration/postcopy: Replace QemuSemaphore with QemuEvent,
Akihiko Odaki <=