thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
1be5c7
From 4051de396e02ea2c1911c842426318bcd97f93c7 Mon Sep 17 00:00:00 2001
1be5c7
From: Juan Quintela <quintela@redhat.com>
1be5c7
Date: Wed, 18 May 2022 02:52:24 -0300
1be5c7
Subject: [PATCH 15/37] multifd: Use a single writev on the send side
1be5c7
MIME-Version: 1.0
1be5c7
Content-Type: text/plain; charset=UTF-8
1be5c7
Content-Transfer-Encoding: 8bit
1be5c7
1be5c7
RH-Author: Leonardo Brás <leobras@redhat.com>
1be5c7
RH-MergeRequest: 191: MSG_ZEROCOPY + Multifd @ rhel8.7
1be5c7
RH-Commit: [15/26] c37063c813fc0ba695072117f272360e5c413803
1be5c7
RH-Bugzilla: 2072049
1be5c7
RH-Acked-by: Peter Xu <peterx@redhat.com>
1be5c7
RH-Acked-by: Daniel P. Berrangé <berrange@redhat.com>
1be5c7
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
1be5c7
1be5c7
Until now, we wrote the packet header with write(), and the rest of the
1be5c7
pages with writev().  Just increase the size of the iovec and do a
1be5c7
single writev().
1be5c7
1be5c7
Signed-off-by: Juan Quintela <quintela@redhat.com>
1be5c7
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
1be5c7
(cherry picked from commit d48c3a044537689866fe44e65d24c7d39a68868a)
1be5c7
Signed-off-by: Leonardo Bras <leobras@redhat.com>
1be5c7
---
1be5c7
 migration/multifd.c | 20 ++++++++------------
1be5c7
 1 file changed, 8 insertions(+), 12 deletions(-)
1be5c7
1be5c7
diff --git a/migration/multifd.c b/migration/multifd.c
1be5c7
index 1e1551d78b..d0f86542b1 100644
1be5c7
--- a/migration/multifd.c
1be5c7
+++ b/migration/multifd.c
1be5c7
@@ -643,7 +643,7 @@ static void *multifd_send_thread(void *opaque)
1be5c7
             uint32_t used = p->pages->num;
1be5c7
             uint64_t packet_num = p->packet_num;
1be5c7
             uint32_t flags = p->flags;
1be5c7
-            p->iovs_num = 0;
1be5c7
+            p->iovs_num = 1;
1be5c7
 
1be5c7
             if (used) {
1be5c7
                 ret = multifd_send_state->ops->send_prepare(p, &local_err);
1be5c7
@@ -663,20 +663,15 @@ static void *multifd_send_thread(void *opaque)
1be5c7
             trace_multifd_send(p->id, packet_num, used, flags,
1be5c7
                                p->next_packet_size);
1be5c7
 
1be5c7
-            ret = qio_channel_write_all(p->c, (void *)p->packet,
1be5c7
-                                        p->packet_len, &local_err);
1be5c7
+            p->iov[0].iov_len = p->packet_len;
1be5c7
+            p->iov[0].iov_base = p->packet;
1be5c7
+
1be5c7
+            ret = qio_channel_writev_all(p->c, p->iov, p->iovs_num,
1be5c7
+                                         &local_err);
1be5c7
             if (ret != 0) {
1be5c7
                 break;
1be5c7
             }
1be5c7
 
1be5c7
-            if (used) {
1be5c7
-                ret = qio_channel_writev_all(p->c, p->iov, p->iovs_num,
1be5c7
-                                             &local_err);
1be5c7
-                if (ret != 0) {
1be5c7
-                    break;
1be5c7
-                }
1be5c7
-            }
1be5c7
-
1be5c7
             qemu_mutex_lock(&p->mutex);
1be5c7
             p->pending_job--;
1be5c7
             qemu_mutex_unlock(&p->mutex);
1be5c7
@@ -913,7 +908,8 @@ int multifd_save_setup(Error **errp)
1be5c7
         p->packet->version = cpu_to_be32(MULTIFD_VERSION);
1be5c7
         p->name = g_strdup_printf("multifdsend_%d", i);
1be5c7
         p->tls_hostname = g_strdup(s->hostname);
1be5c7
-        p->iov = g_new0(struct iovec, page_count);
1be5c7
+        /* We need one extra place for the packet header */
1be5c7
+        p->iov = g_new0(struct iovec, page_count + 1);
1be5c7
         socket_send_channel_create(multifd_new_send_channel_async, p);
1be5c7
     }
1be5c7
 
1be5c7
-- 
1be5c7
2.35.3
1be5c7