cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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