Blame SOURCES/kvm-multifd-Make-zlib-compression-method-not-use-iovs.patch

1be5c7
From 75cd92cb7cff055f46163e64d66ba3f685f9ac04 Mon Sep 17 00:00:00 2001
1be5c7
From: Juan Quintela <quintela@redhat.com>
1be5c7
Date: Wed, 18 May 2022 02:52:23 -0300
1be5c7
Subject: [PATCH 09/37] multifd: Make zlib compression method not use iovs
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: [9/26] d33dd62b833d50fee989a195aebcc8d5e7d43181
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
Signed-off-by: Juan Quintela <quintela@redhat.com>
1be5c7
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
1be5c7
(cherry picked from commit a5ed22948873b50fcf1415d1ce15c71d61a9388d)
1be5c7
Signed-off-by: Leonardo Bras <leobras@redhat.com>
1be5c7
---
1be5c7
 migration/multifd-zlib.c | 17 +++++++++--------
1be5c7
 1 file changed, 9 insertions(+), 8 deletions(-)
1be5c7
1be5c7
diff --git a/migration/multifd-zlib.c b/migration/multifd-zlib.c
1be5c7
index 330fc021c5..a1950a4588 100644
1be5c7
--- a/migration/multifd-zlib.c
1be5c7
+++ b/migration/multifd-zlib.c
1be5c7
@@ -13,6 +13,7 @@
1be5c7
 #include "qemu/osdep.h"
1be5c7
 #include <zlib.h>
1be5c7
 #include "qemu/rcu.h"
1be5c7
+#include "exec/ramblock.h"
1be5c7
 #include "exec/target_page.h"
1be5c7
 #include "qapi/error.h"
1be5c7
 #include "migration.h"
1be5c7
@@ -100,8 +101,8 @@ static void zlib_send_cleanup(MultiFDSendParams *p, Error **errp)
1be5c7
  */
1be5c7
 static int zlib_send_prepare(MultiFDSendParams *p, Error **errp)
1be5c7
 {
1be5c7
-    struct iovec *iov = p->pages->iov;
1be5c7
     struct zlib_data *z = p->data;
1be5c7
+    size_t page_size = qemu_target_page_size();
1be5c7
     z_stream *zs = &z->zs;
1be5c7
     uint32_t out_size = 0;
1be5c7
     int ret;
1be5c7
@@ -115,8 +116,8 @@ static int zlib_send_prepare(MultiFDSendParams *p, Error **errp)
1be5c7
             flush = Z_SYNC_FLUSH;
1be5c7
         }
1be5c7
 
1be5c7
-        zs->avail_in = iov[i].iov_len;
1be5c7
-        zs->next_in = iov[i].iov_base;
1be5c7
+        zs->avail_in = page_size;
1be5c7
+        zs->next_in = p->pages->block->host + p->pages->offset[i];
1be5c7
 
1be5c7
         zs->avail_out = available;
1be5c7
         zs->next_out = z->zbuff + out_size;
1be5c7
@@ -240,6 +241,7 @@ static void zlib_recv_cleanup(MultiFDRecvParams *p)
1be5c7
 static int zlib_recv_pages(MultiFDRecvParams *p, Error **errp)
1be5c7
 {
1be5c7
     struct zlib_data *z = p->data;
1be5c7
+    size_t page_size = qemu_target_page_size();
1be5c7
     z_stream *zs = &z->zs;
1be5c7
     uint32_t in_size = p->next_packet_size;
1be5c7
     /* we measure the change of total_out */
1be5c7
@@ -264,7 +266,6 @@ static int zlib_recv_pages(MultiFDRecvParams *p, Error **errp)
1be5c7
     zs->next_in = z->zbuff;
1be5c7
 
1be5c7
     for (i = 0; i < p->pages->num; i++) {
1be5c7
-        struct iovec *iov = &p->pages->iov[i];
1be5c7
         int flush = Z_NO_FLUSH;
1be5c7
         unsigned long start = zs->total_out;
1be5c7
 
1be5c7
@@ -272,8 +273,8 @@ static int zlib_recv_pages(MultiFDRecvParams *p, Error **errp)
1be5c7
             flush = Z_SYNC_FLUSH;
1be5c7
         }
1be5c7
 
1be5c7
-        zs->avail_out = iov->iov_len;
1be5c7
-        zs->next_out = iov->iov_base;
1be5c7
+        zs->avail_out = page_size;
1be5c7
+        zs->next_out = p->pages->block->host + p->pages->offset[i];
1be5c7
 
1be5c7
         /*
1be5c7
          * Welcome to inflate semantics
1be5c7
@@ -286,8 +287,8 @@ static int zlib_recv_pages(MultiFDRecvParams *p, Error **errp)
1be5c7
         do {
1be5c7
             ret = inflate(zs, flush);
1be5c7
         } while (ret == Z_OK && zs->avail_in
1be5c7
-                             && (zs->total_out - start) < iov->iov_len);
1be5c7
-        if (ret == Z_OK && (zs->total_out - start) < iov->iov_len) {
1be5c7
+                             && (zs->total_out - start) < page_size);
1be5c7
+        if (ret == Z_OK && (zs->total_out - start) < page_size) {
1be5c7
             error_setg(errp, "multifd %d: inflate generated too few output",
1be5c7
                        p->id);
1be5c7
             return -1;
1be5c7
-- 
1be5c7
2.35.3
1be5c7