[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/27] migration/multifd: Cleanup multifd_recv_sync_main
From: |
peterx |
Subject: |
[PULL 04/27] migration/multifd: Cleanup multifd_recv_sync_main |
Date: |
Mon, 4 Mar 2024 09:26:11 +0800 |
From: Fabiano Rosas <farosas@suse.de>
Some minor cleanups and documentation for multifd_recv_sync_main.
Use thread_count as done in other parts of the code. Remove p->id from
the multifd_recv_state sync, since that is global and not tied to a
channel. Add documentation for the sync steps.
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20240229153017.2221-2-farosas@suse.de
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/multifd.c | 17 +++++++++++++----
migration/trace-events | 2 +-
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/migration/multifd.c b/migration/multifd.c
index 6c07f19af1..c7389bf833 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -1182,18 +1182,27 @@ void multifd_recv_cleanup(void)
void multifd_recv_sync_main(void)
{
+ int thread_count = migrate_multifd_channels();
int i;
if (!migrate_multifd()) {
return;
}
- for (i = 0; i < migrate_multifd_channels(); i++) {
- MultiFDRecvParams *p = &multifd_recv_state->params[i];
- trace_multifd_recv_sync_main_wait(p->id);
+ /*
+ * Initiate the synchronization by waiting for all channels.
+ * For socket-based migration this means each channel has received
+ * the SYNC packet on the stream.
+ */
+ for (i = 0; i < thread_count; i++) {
+ trace_multifd_recv_sync_main_wait(i);
qemu_sem_wait(&multifd_recv_state->sem_sync);
}
- for (i = 0; i < migrate_multifd_channels(); i++) {
+
+ /*
+ * Sync done. Release the channels for the next iteration.
+ */
+ for (i = 0; i < thread_count; i++) {
MultiFDRecvParams *p = &multifd_recv_state->params[i];
WITH_QEMU_LOCK_GUARD(&p->mutex) {
diff --git a/migration/trace-events b/migration/trace-events
index 298ad2b0dd..bf1a069632 100644
--- a/migration/trace-events
+++ b/migration/trace-events
@@ -132,7 +132,7 @@ multifd_recv(uint8_t id, uint64_t packet_num, uint32_t
used, uint32_t flags, uin
multifd_recv_new_channel(uint8_t id) "channel %u"
multifd_recv_sync_main(long packet_num) "packet num %ld"
multifd_recv_sync_main_signal(uint8_t id) "channel %u"
-multifd_recv_sync_main_wait(uint8_t id) "channel %u"
+multifd_recv_sync_main_wait(uint8_t id) "iter %u"
multifd_recv_terminate_threads(bool error) "error %d"
multifd_recv_thread_end(uint8_t id, uint64_t packets, uint64_t pages) "channel
%u packets %" PRIu64 " pages %" PRIu64
multifd_recv_thread_start(uint8_t id) "%u"
--
2.44.0
- [PULL 00/27] Migration next patches, peterx, 2024/03/03
- [PULL 01/27] migration: massage cpr-reboot documentation, peterx, 2024/03/03
- [PULL 02/27] migration: Properly apply migration compression level parameters, peterx, 2024/03/03
- [PULL 04/27] migration/multifd: Cleanup multifd_recv_sync_main,
peterx <=
- [PULL 05/27] io: add and implement QIO_CHANNEL_FEATURE_SEEKABLE for channel file, peterx, 2024/03/03
- [PULL 03/27] tests/migration: Set compression level in migration tests, peterx, 2024/03/03
- [PULL 07/27] io: implement io_pwritev/preadv for QIOChannelFile, peterx, 2024/03/03
- [PULL 08/27] io: fsync before closing a file channel, peterx, 2024/03/03
- [PULL 06/27] io: Add generic pwritev/preadv interface, peterx, 2024/03/03
- [PULL 10/27] migration/ram: Introduce 'mapped-ram' migration capability, peterx, 2024/03/03
- [PULL 11/27] migration: Add mapped-ram URI compatibility check, peterx, 2024/03/03
- [PULL 09/27] migration/qemu-file: add utility methods for working with seekable channels, peterx, 2024/03/03
- [PULL 12/27] migration/ram: Add outgoing 'mapped-ram' migration, peterx, 2024/03/03
- [PULL 13/27] migration/ram: Add incoming 'mapped-ram' migration, peterx, 2024/03/03