From: Fabiano Rosas <farosas@suse.de>
To: qemu-devel@nongnu.org
Cc: Juan Quintela <quintela@redhat.com>, Peter Xu <peterx@redhat.com>,
Leonardo Bras <leobras@redhat.com>,
Elena Ufimtseva <elena.ufimtseva@oracle.com>
Subject: [RFC PATCH 3/3] migration/multifd: Extract sem_done waiting into a function
Date: Fri, 22 Sep 2023 11:53:19 -0300 [thread overview]
Message-ID: <20230922145319.27380-4-farosas@suse.de> (raw)
In-Reply-To: <20230922145319.27380-1-farosas@suse.de>
This helps document the intent of the loop via the function name and
we can reuse this in the future.
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
migration/multifd.c | 38 +++++---------------------------------
1 file changed, 5 insertions(+), 33 deletions(-)
diff --git a/migration/multifd.c b/migration/multifd.c
index 3d4a631915..159225530d 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -585,24 +585,14 @@ static int multifd_zero_copy_flush(QIOChannel *c)
return ret;
}
-int multifd_send_sync_main(QEMUFile *f)
+static int multifd_send_wait(void)
{
- int i;
bool flush_zero_copy;
-
- if (!migrate_multifd()) {
- return 0;
-
- if (multifd_send_state->pages->num) {
- if (multifd_send_pages(f) < 0) {
- error_report("%s: multifd_send_pages fail", __func__);
- return -1;
- }
- }
+ int i;
/* wait for all channels to be idle */
for (i = 0; i < migrate_multifd_channels(); i++) {
- trace_multifd_send_sync_main_wait(p->id);
+ trace_multifd_send_wait(migrate_multifd_channels() - i);
qemu_sem_wait(&multifd_send_state->channels_ready);
}
@@ -677,28 +667,10 @@ int multifd_send_sync_main(QEMUFile *f)
qemu_sem_post(&p->sem);
}
- for (i = 0; i < migrate_multifd_channels(); i++) {
- trace_multifd_send_wait(migrate_multifd_channels() - i);
- qemu_sem_wait(&multifd_send_state->channels_ready);
- }
-
- for (i = 0; i < migrate_multifd_channels(); i++) {
- MultiFDSendParams *p = &multifd_send_state->params[i];
-
- qemu_mutex_lock(&p->mutex);
- assert(!p->pending_job);
- qemu_mutex_unlock(&p->mutex);
-
- qemu_sem_post(&p->sem);
- qemu_sem_wait(&p->sem_done);
-
- if (flush_zero_copy && p->c && (multifd_zero_copy_flush(p->c) < 0)) {
- return -1;
- }
- }
+ ret = multifd_send_wait();
trace_multifd_send_sync_main(multifd_send_state->packet_num);
- return 0;
+ return ret;
}
static void *multifd_send_thread(void *opaque)
--
2.35.3
prev parent reply other threads:[~2023-09-22 14:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-22 14:53 [RFC PATCH 0/3] migration/multifd: SYNC packet changes Fabiano Rosas
2023-09-22 14:53 ` [RFC PATCH 1/3] migration/multifd: Move channels_ready semaphore Fabiano Rosas
2023-09-22 22:33 ` Elena Ufimtseva
2023-09-29 14:41 ` Fabiano Rosas
2023-10-10 21:00 ` Peter Xu
2023-10-10 21:40 ` Peter Xu
2023-10-10 21:43 ` Fabiano Rosas
2023-10-10 21:59 ` Peter Xu
2023-09-22 14:53 ` [RFC PATCH 2/3] migration/multifd: Decouple control flow from the SYNC packet Fabiano Rosas
2023-09-22 14:53 ` Fabiano Rosas [this message]
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=20230922145319.27380-4-farosas@suse.de \
--to=farosas@suse.de \
--cc=elena.ufimtseva@oracle.com \
--cc=leobras@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).