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

1bdc94
From 991ad76f13534cd2f22b30ba8b556f284f28c5c6 Mon Sep 17 00:00:00 2001
1bdc94
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
1bdc94
Date: Fri, 22 Jun 2018 18:59:48 +0200
1bdc94
Subject: [PATCH 09/57] migration: stop compressing page in migration thread
1bdc94
1bdc94
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
1bdc94
Message-id: <20180622190005.21297-2-dgilbert@redhat.com>
1bdc94
Patchwork-id: 81005
1bdc94
O-Subject: [RHEL7.6 qemu-kvm-rhev PATCH 01/18] migration: stop compressing page in migration thread
1bdc94
Bugzilla: 1584139
1bdc94
RH-Acked-by: Juan Quintela <quintela@redhat.com>
1bdc94
RH-Acked-by: Peter Xu <peterx@redhat.com>
1bdc94
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
1bdc94
1bdc94
From: Xiao Guangrong <xiaoguangrong@tencent.com>
1bdc94
1bdc94
As compression is a heavy work, do not do it in migration thread,
1bdc94
instead, we post it out as a normal page
1bdc94
1bdc94
Reviewed-by: Wei Wang <wei.w.wang@intel.com>
1bdc94
Reviewed-by: Peter Xu <peterx@redhat.com>
1bdc94
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
1bdc94
Signed-off-by: Xiao Guangrong <xiaoguangrong@tencent.com>
1bdc94
Message-Id: <20180330075128.26919-2-xiaoguangrong@tencent.com>
1bdc94
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
1bdc94
(cherry picked from commit 263a289ae61c8344a417a95b0142650fdff3af56)
1bdc94
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
1bdc94
---
1bdc94
 migration/ram.c | 32 ++++++++++++++++----------------
1bdc94
 1 file changed, 16 insertions(+), 16 deletions(-)
1bdc94
1bdc94
diff --git a/migration/ram.c b/migration/ram.c
1bdc94
index 00c06b5..f27038a 100644
1bdc94
--- a/migration/ram.c
1bdc94
+++ b/migration/ram.c
1bdc94
@@ -1138,7 +1138,7 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss,
1bdc94
     int pages = -1;
1bdc94
     uint64_t bytes_xmit = 0;
1bdc94
     uint8_t *p;
1bdc94
-    int ret, blen;
1bdc94
+    int ret;
1bdc94
     RAMBlock *block = pss->block;
1bdc94
     ram_addr_t offset = pss->page << TARGET_PAGE_BITS;
1bdc94
 
1bdc94
@@ -1168,23 +1168,23 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss,
1bdc94
         if (block != rs->last_sent_block) {
1bdc94
             flush_compressed_data(rs);
1bdc94
             pages = save_zero_page(rs, block, offset);
1bdc94
-            if (pages == -1) {
1bdc94
-                /* Make sure the first page is sent out before other pages */
1bdc94
-                bytes_xmit = save_page_header(rs, rs->f, block, offset |
1bdc94
-                                              RAM_SAVE_FLAG_COMPRESS_PAGE);
1bdc94
-                blen = qemu_put_compression_data(rs->f, p, TARGET_PAGE_SIZE,
1bdc94
-                                                 migrate_compress_level());
1bdc94
-                if (blen > 0) {
1bdc94
-                    ram_counters.transferred += bytes_xmit + blen;
1bdc94
-                    ram_counters.normal++;
1bdc94
-                    pages = 1;
1bdc94
-                } else {
1bdc94
-                    qemu_file_set_error(rs->f, blen);
1bdc94
-                    error_report("compressed data failed!");
1bdc94
-                }
1bdc94
-            }
1bdc94
             if (pages > 0) {
1bdc94
                 ram_release_pages(block->idstr, offset, pages);
1bdc94
+            } else {
1bdc94
+                /*
1bdc94
+                 * Make sure the first page is sent out before other pages.
1bdc94
+                 *
1bdc94
+                 * we post it as normal page as compression will take much
1bdc94
+                 * CPU resource.
1bdc94
+                 */
1bdc94
+                ram_counters.transferred += save_page_header(rs, rs->f, block,
1bdc94
+                                                offset | RAM_SAVE_FLAG_PAGE);
1bdc94
+                qemu_put_buffer_async(rs->f, p, TARGET_PAGE_SIZE,
1bdc94
+                                      migrate_release_ram() &
1bdc94
+                                      migration_in_postcopy());
1bdc94
+                ram_counters.transferred += TARGET_PAGE_SIZE;
1bdc94
+                ram_counters.normal++;
1bdc94
+                pages = 1;
1bdc94
             }
1bdc94
         } else {
1bdc94
             pages = save_zero_page(rs, block, offset);
1bdc94
-- 
1bdc94
1.8.3.1
1bdc94