thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

1be5c7
From ab6262bd4829e3bd6437fe32737209df2af2d141 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 08/37] multifd: Make zstd 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: [8/26] 010579fa73b5a4c6fd631dc9fbaf6f974974bc99
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 f5ff548774c22b34a0c0e2fef85f1be11160d774)
1be5c7
Signed-off-by: Leonardo Bras <leobras@redhat.com>
1be5c7
---
1be5c7
 migration/multifd-zstd.c | 20 ++++++++++----------
1be5c7
 1 file changed, 10 insertions(+), 10 deletions(-)
1be5c7
1be5c7
diff --git a/migration/multifd-zstd.c b/migration/multifd-zstd.c
1be5c7
index f0d1105792..d9ed42622b 100644
1be5c7
--- a/migration/multifd-zstd.c
1be5c7
+++ b/migration/multifd-zstd.c
1be5c7
@@ -13,6 +13,7 @@
1be5c7
 #include "qemu/osdep.h"
1be5c7
 #include <zstd.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
@@ -113,8 +114,8 @@ static void zstd_send_cleanup(MultiFDSendParams *p, Error **errp)
1be5c7
  */
1be5c7
 static int zstd_send_prepare(MultiFDSendParams *p, Error **errp)
1be5c7
 {
1be5c7
-    struct iovec *iov = p->pages->iov;
1be5c7
     struct zstd_data *z = p->data;
1be5c7
+    size_t page_size = qemu_target_page_size();
1be5c7
     int ret;
1be5c7
     uint32_t i;
1be5c7
 
1be5c7
@@ -128,8 +129,8 @@ static int zstd_send_prepare(MultiFDSendParams *p, Error **errp)
1be5c7
         if (i == p->pages->num - 1) {
1be5c7
             flush = ZSTD_e_flush;
1be5c7
         }
1be5c7
-        z->in.src = iov[i].iov_base;
1be5c7
-        z->in.size = iov[i].iov_len;
1be5c7
+        z->in.src = p->pages->block->host + p->pages->offset[i];
1be5c7
+        z->in.size = page_size;
1be5c7
         z->in.pos = 0;
1be5c7
 
1be5c7
         /*
1be5c7
@@ -261,7 +262,8 @@ static int zstd_recv_pages(MultiFDRecvParams *p, Error **errp)
1be5c7
 {
1be5c7
     uint32_t in_size = p->next_packet_size;
1be5c7
     uint32_t out_size = 0;
1be5c7
-    uint32_t expected_size = p->pages->num * qemu_target_page_size();
1be5c7
+    size_t page_size = qemu_target_page_size();
1be5c7
+    uint32_t expected_size = p->pages->num * page_size;
1be5c7
     uint32_t flags = p->flags & MULTIFD_FLAG_COMPRESSION_MASK;
1be5c7
     struct zstd_data *z = p->data;
1be5c7
     int ret;
1be5c7
@@ -283,10 +285,8 @@ static int zstd_recv_pages(MultiFDRecvParams *p, Error **errp)
1be5c7
     z->in.pos = 0;
1be5c7
 
1be5c7
     for (i = 0; i < p->pages->num; i++) {
1be5c7
-        struct iovec *iov = &p->pages->iov[i];
1be5c7
-
1be5c7
-        z->out.dst = iov->iov_base;
1be5c7
-        z->out.size = iov->iov_len;
1be5c7
+        z->out.dst = p->pages->block->host + p->pages->offset[i];
1be5c7
+        z->out.size = page_size;
1be5c7
         z->out.pos = 0;
1be5c7
 
1be5c7
         /*
1be5c7
@@ -300,8 +300,8 @@ static int zstd_recv_pages(MultiFDRecvParams *p, Error **errp)
1be5c7
         do {
1be5c7
             ret = ZSTD_decompressStream(z->zds, &z->out, &z->in);
1be5c7
         } while (ret > 0 && (z->in.size - z->in.pos > 0)
1be5c7
-                         && (z->out.pos < iov->iov_len));
1be5c7
-        if (ret > 0 && (z->out.pos < iov->iov_len)) {
1be5c7
+                         && (z->out.pos < page_size));
1be5c7
+        if (ret > 0 && (z->out.pos < page_size)) {
1be5c7
             error_setg(errp, "multifd %d: decompressStream buffer too small",
1be5c7
                        p->id);
1be5c7
             return -1;
1be5c7
-- 
1be5c7
2.35.3
1be5c7