thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-migration-stop-compressing-page-in-migration-thread.patch

ae23c9
From 932d0761f1f473638a38614796bd14939cdd6215 Mon Sep 17 00:00:00 2001
ae23c9
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
ae23c9
Date: Wed, 1 Aug 2018 13:55:05 +0100
ae23c9
Subject: [PATCH 01/21] migration: stop compressing page in migration thread
ae23c9
ae23c9
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
ae23c9
Message-id: <20180801135522.11658-2-dgilbert@redhat.com>
ae23c9
Patchwork-id: 81577
ae23c9
O-Subject: [qemu-kvm RHEL8/virt212 PATCH 01/18] migration: stop compressing page in migration thread
ae23c9
Bugzilla: 1594384
ae23c9
RH-Acked-by: Peter Xu <peterx@redhat.com>
ae23c9
RH-Acked-by: John Snow <jsnow@redhat.com>
ae23c9
RH-Acked-by: Juan Quintela <quintela@redhat.com>
ae23c9
ae23c9
From: Xiao Guangrong <xiaoguangrong@tencent.com>
ae23c9
ae23c9
As compression is a heavy work, do not do it in migration thread,
ae23c9
instead, we post it out as a normal page
ae23c9
ae23c9
Reviewed-by: Wei Wang <wei.w.wang@intel.com>
ae23c9
Reviewed-by: Peter Xu <peterx@redhat.com>
ae23c9
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
ae23c9
Signed-off-by: Xiao Guangrong <xiaoguangrong@tencent.com>
ae23c9
Message-Id: <20180330075128.26919-2-xiaoguangrong@tencent.com>
ae23c9
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
ae23c9
(cherry picked from commit 263a289ae61c8344a417a95b0142650fdff3af56)
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 migration/ram.c | 32 ++++++++++++++++----------------
ae23c9
 1 file changed, 16 insertions(+), 16 deletions(-)
ae23c9
ae23c9
diff --git a/migration/ram.c b/migration/ram.c
ae23c9
index 00c06b5..f27038a 100644
ae23c9
--- a/migration/ram.c
ae23c9
+++ b/migration/ram.c
ae23c9
@@ -1138,7 +1138,7 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss,
ae23c9
     int pages = -1;
ae23c9
     uint64_t bytes_xmit = 0;
ae23c9
     uint8_t *p;
ae23c9
-    int ret, blen;
ae23c9
+    int ret;
ae23c9
     RAMBlock *block = pss->block;
ae23c9
     ram_addr_t offset = pss->page << TARGET_PAGE_BITS;
ae23c9
 
ae23c9
@@ -1168,23 +1168,23 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss,
ae23c9
         if (block != rs->last_sent_block) {
ae23c9
             flush_compressed_data(rs);
ae23c9
             pages = save_zero_page(rs, block, offset);
ae23c9
-            if (pages == -1) {
ae23c9
-                /* Make sure the first page is sent out before other pages */
ae23c9
-                bytes_xmit = save_page_header(rs, rs->f, block, offset |
ae23c9
-                                              RAM_SAVE_FLAG_COMPRESS_PAGE);
ae23c9
-                blen = qemu_put_compression_data(rs->f, p, TARGET_PAGE_SIZE,
ae23c9
-                                                 migrate_compress_level());
ae23c9
-                if (blen > 0) {
ae23c9
-                    ram_counters.transferred += bytes_xmit + blen;
ae23c9
-                    ram_counters.normal++;
ae23c9
-                    pages = 1;
ae23c9
-                } else {
ae23c9
-                    qemu_file_set_error(rs->f, blen);
ae23c9
-                    error_report("compressed data failed!");
ae23c9
-                }
ae23c9
-            }
ae23c9
             if (pages > 0) {
ae23c9
                 ram_release_pages(block->idstr, offset, pages);
ae23c9
+            } else {
ae23c9
+                /*
ae23c9
+                 * Make sure the first page is sent out before other pages.
ae23c9
+                 *
ae23c9
+                 * we post it as normal page as compression will take much
ae23c9
+                 * CPU resource.
ae23c9
+                 */
ae23c9
+                ram_counters.transferred += save_page_header(rs, rs->f, block,
ae23c9
+                                                offset | RAM_SAVE_FLAG_PAGE);
ae23c9
+                qemu_put_buffer_async(rs->f, p, TARGET_PAGE_SIZE,
ae23c9
+                                      migrate_release_ram() &
ae23c9
+                                      migration_in_postcopy());
ae23c9
+                ram_counters.transferred += TARGET_PAGE_SIZE;
ae23c9
+                ram_counters.normal++;
ae23c9
+                pages = 1;
ae23c9
             }
ae23c9
         } else {
ae23c9
             pages = save_zero_page(rs, block, offset);
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9