[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 03/34] migration/multifd: multifd_send_kick_main()
From: |
peterx |
Subject: |
[PULL 03/34] migration/multifd: multifd_send_kick_main() |
Date: |
Thu, 8 Feb 2024 11:04:57 +0800 |
From: Peter Xu <peterx@redhat.com>
When a multifd sender thread hit errors, it always needs to kick the main
thread by kicking all the semaphores that it can be waiting upon.
Provide a helper for it and deduplicate the code.
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: 20240202102857.110210-3-peterx@redhat.com">https://lore.kernel.org/r/20240202102857.110210-3-peterx@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/multifd.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/migration/multifd.c b/migration/multifd.c
index eee2586770..b8d2c96533 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -372,6 +372,18 @@ struct {
MultiFDMethods *ops;
} *multifd_send_state;
+/*
+ * The migration thread can wait on either of the two semaphores. This
+ * function can be used to kick the main thread out of waiting on either of
+ * them. Should mostly only be called when something wrong happened with
+ * the current multifd send thread.
+ */
+static void multifd_send_kick_main(MultiFDSendParams *p)
+{
+ qemu_sem_post(&p->sem_sync);
+ qemu_sem_post(&multifd_send_state->channels_ready);
+}
+
/*
* How we use multifd_send_state->pages and channel->pages?
*
@@ -739,8 +751,7 @@ out:
assert(local_err);
trace_multifd_send_error(p->id);
multifd_send_terminate_threads(local_err);
- qemu_sem_post(&p->sem_sync);
- qemu_sem_post(&multifd_send_state->channels_ready);
+ multifd_send_kick_main(p);
error_free(local_err);
}
@@ -781,8 +792,7 @@ static void multifd_tls_outgoing_handshake(QIOTask *task,
* is not created, and then tell who pay attention to me.
*/
p->quit = true;
- qemu_sem_post(&multifd_send_state->channels_ready);
- qemu_sem_post(&p->sem_sync);
+ multifd_send_kick_main(p);
error_free(err);
}
@@ -852,8 +862,7 @@ static void
multifd_new_send_channel_cleanup(MultiFDSendParams *p,
{
migrate_set_error(migrate_get_current(), err);
/* Error happen, we need to tell who pay attention to me */
- qemu_sem_post(&multifd_send_state->channels_ready);
- qemu_sem_post(&p->sem_sync);
+ multifd_send_kick_main(p);
/*
* Although multifd_send_thread is not created, but main migration
* thread need to judge whether it is running, so we need to mark
--
2.43.0
- [PULL 00/34] Migration staging patches, peterx, 2024/02/07
- [PULL 01/34] migration: prevent migration when VM has poisoned memory, peterx, 2024/02/07
- [PULL 02/34] migration/multifd: Drop stale comment for multifd zero copy, peterx, 2024/02/07
- [PULL 03/34] migration/multifd: multifd_send_kick_main(),
peterx <=
- [PULL 05/34] migration/multifd: Postpone reset of MultiFDPages_t, peterx, 2024/02/07
- [PULL 06/34] migration/multifd: Drop MultiFDSendParams.normal[] array, peterx, 2024/02/07
- [PULL 07/34] migration/multifd: Separate SYNC request with normal jobs, peterx, 2024/02/07
- [PULL 04/34] migration/multifd: Drop MultiFDSendParams.quit, cleanup error paths, peterx, 2024/02/07
- [PULL 08/34] migration/multifd: Simplify locking in sender thread, peterx, 2024/02/07
- [PULL 09/34] migration/multifd: Drop pages->num check in sender thread, peterx, 2024/02/07
- [PULL 13/34] migration/multifd: multifd_send_prepare_header(), peterx, 2024/02/07
- [PULL 10/34] migration/multifd: Rename p->num_packets and clean it up, peterx, 2024/02/07
- [PULL 20/34] migration/multifd: Cleanup multifd_save_cleanup(), peterx, 2024/02/07
- [PULL 21/34] migration/multifd: Cleanup multifd_load_cleanup(), peterx, 2024/02/07