[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 12/23] migration/multifd: multifd_send_prepare_header()
From: |
peterx |
Subject: |
[PATCH v2 12/23] migration/multifd: multifd_send_prepare_header() |
Date: |
Fri, 2 Feb 2024 18:28:46 +0800 |
From: Peter Xu <peterx@redhat.com>
Introduce a helper multifd_send_prepare_header() to setup the header packet
for multifd sender.
It's fine to setup the IOV[0] _before_ send_prepare() because the packet
buffer is already ready, even if the content is to be filled in.
With this helper, we can already slightly clean up the zero copy path.
Note that I explicitly put it into multifd.h, because I want it inlined
directly into multifd*.c where necessary later.
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/multifd.h | 8 ++++++++
migration/multifd.c | 16 ++++++++--------
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/migration/multifd.h b/migration/multifd.h
index 2e4ad0dc56..4ec005f53f 100644
--- a/migration/multifd.h
+++ b/migration/multifd.h
@@ -209,5 +209,13 @@ typedef struct {
void multifd_register_ops(int method, MultiFDMethods *ops);
+static inline void multifd_send_prepare_header(MultiFDSendParams *p)
+{
+ p->iov[0].iov_len = p->packet_len;
+ p->iov[0].iov_base = p->packet;
+ p->iovs_num++;
+}
+
+
#endif
diff --git a/migration/multifd.c b/migration/multifd.c
index 44163e4e28..cd4467aff4 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -712,10 +712,14 @@ static void *multifd_send_thread(void *opaque)
if (qatomic_read(&p->pending_job)) {
MultiFDPages_t *pages = p->pages;
- if (use_zero_copy_send) {
- p->iovs_num = 0;
- } else {
- p->iovs_num = 1;
+ p->iovs_num = 0;
+
+ if (!use_zero_copy_send) {
+ /*
+ * Only !zerocopy needs the header in IOV; zerocopy will
+ * send it separately.
+ */
+ multifd_send_prepare_header(p);
}
assert(pages->num);
@@ -735,10 +739,6 @@ static void *multifd_send_thread(void *opaque)
if (ret != 0) {
break;
}
- } else {
- /* Send header using the same writev call */
- p->iov[0].iov_len = p->packet_len;
- p->iov[0].iov_base = p->packet;
}
ret = qio_channel_writev_full_all(p->c, p->iov, p->iovs_num, NULL,
--
2.43.0
- [PATCH v2 06/23] migration/multifd: Separate SYNC request with normal jobs, (continued)
- [PATCH v2 06/23] migration/multifd: Separate SYNC request with normal jobs, peterx, 2024/02/02
- [PATCH v2 07/23] migration/multifd: Simplify locking in sender thread, peterx, 2024/02/02
- [PATCH v2 08/23] migration/multifd: Drop pages->num check in sender thread, peterx, 2024/02/02
- [PATCH v2 09/23] migration/multifd: Rename p->num_packets and clean it up, peterx, 2024/02/02
- [PATCH v2 10/23] migration/multifd: Move total_normal_pages accounting, peterx, 2024/02/02
- [PATCH v2 11/23] migration/multifd: Move trace_multifd_send|recv(), peterx, 2024/02/02
- [PATCH v2 13/23] migration/multifd: Move header prepare/fill into send_prepare(), peterx, 2024/02/02
- [PATCH v2 12/23] migration/multifd: multifd_send_prepare_header(),
peterx <=
- [PATCH v2 14/23] migration/multifd: Forbid spurious wakeups, peterx, 2024/02/02
- [PATCH v2 15/23] migration/multifd: Split multifd_send_terminate_threads(), peterx, 2024/02/02
- [PATCH v2 17/23] migration/multifd: Change retval of multifd_send_pages(), peterx, 2024/02/02
- [PATCH v2 16/23] migration/multifd: Change retval of multifd_queue_page(), peterx, 2024/02/02
- [PATCH v2 18/23] migration/multifd: Rewrite multifd_queue_page(), peterx, 2024/02/02