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

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