From: Fabiano Rosas <farosas@suse.de>
To: Bin Guo <guobin@linux.alibaba.com>, qemu-devel@nongnu.org
Cc: peterx@redhat.com
Subject: Re: [PATCH 6/8] migration/multifd: merge thread-join and cleanup loops in multifd_recv_cleanup
Date: Mon, 18 May 2026 17:21:17 -0300 [thread overview]
Message-ID: <87bjec4gg2.fsf@suse.de> (raw)
In-Reply-To: <20260518110112.21395-7-guobin@linux.alibaba.com>
Bin Guo <guobin@linux.alibaba.com> writes:
> multifd_recv_cleanup() iterates over all receive channels twice:
> one loop to join threads and another to clean up each channel.
ok
> Unlike the send side where all threads must be signalled before any is
> joined (to avoid deadlock),
Not super relevant what the send side does. It's just a similar piece of
code, that's all.
> on the receive side the threads are already
> terminated by multifd_recv_terminate_threads(). Each join simply
> waits for an already-terminated thread, so the join and cleanup for
> channel i are independent of channel j, and the two loops can safely
> be merged into one.
>
We do really need to join all threads before proceeding. There's no
guarantee on the the order in which they'll terminate.
> This cuts the iteration count in half and improves locality: the
> thread's resources are freed immediately after its join.
>
> Signed-off-by: Bin Guo <guobin@linux.alibaba.com>
> ---
> migration/multifd.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/migration/multifd.c b/migration/multifd.c
> index b3eef875cc..67ee9bdf5e 100644
> --- a/migration/multifd.c
> +++ b/migration/multifd.c
> @@ -1153,15 +1153,14 @@ void multifd_recv_cleanup(void)
> return;
> }
> multifd_recv_terminate_threads(NULL);
> +
> for (i = 0; i < migrate_multifd_channels(); i++) {
> MultiFDRecvParams *p = &multifd_recv_state->params[i];
>
> if (p->thread_created) {
> qemu_thread_join(&p->thread);
> }
> - }
> - for (i = 0; i < migrate_multifd_channels(); i++) {
> - multifd_recv_cleanup_channel(&multifd_recv_state->params[i]);
> + multifd_recv_cleanup_channel(p);
> }
> multifd_recv_cleanup_state();
> }
next prev parent reply other threads:[~2026-05-18 20:22 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 11:01 [PATCH 0/8] migration: cleanups, fixes and micro-optimizations Bin Guo
2026-05-18 11:01 ` [PATCH 1/8] migration/fd: collapse migration_fd_valid into single boolean expression Bin Guo
2026-05-18 20:22 ` Fabiano Rosas
2026-05-18 11:01 ` [PATCH 2/8] migration/global_state: replace strcpy("") with explicit NUL termination Bin Guo
2026-05-18 20:32 ` Fabiano Rosas
2026-05-18 11:01 ` [PATCH 3/8] migration/vmstate: avoid per-element heap churn in vmsd ptr marker field Bin Guo
2026-05-19 7:32 ` Fabiano Rosas
2026-05-18 11:01 ` [PATCH 4/8] migration/savevm: use stack-allocated bitmap in configuration_validate_capabilities Bin Guo
2026-05-18 20:53 ` Fabiano Rosas
2026-05-18 11:01 ` [PATCH 5/8] migration/multifd: fix off-by-one in recv channel ID validation Bin Guo
2026-05-18 19:43 ` Fabiano Rosas
2026-05-18 11:01 ` [PATCH 6/8] migration/multifd: merge thread-join and cleanup loops in multifd_recv_cleanup Bin Guo
2026-05-18 20:21 ` Fabiano Rosas [this message]
2026-05-18 11:01 ` [PATCH 7/8] migration/multifd: cache migrate_multifd_channels() in send/recv hot paths Bin Guo
2026-05-19 7:16 ` Fabiano Rosas
2026-05-18 11:01 ` [PATCH 8/8] migration/multifd: cache channel count in multifd_send_sync_main Bin Guo
2026-05-19 7:17 ` Fabiano Rosas
2026-05-20 19:33 ` [PATCH 0/8] migration: cleanups, fixes and micro-optimizations Peter Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bjec4gg2.fsf@suse.de \
--to=farosas@suse.de \
--cc=guobin@linux.alibaba.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.