Blame SOURCES/kvm-migration-introduce-save_normal_page.patch

357786
From 45b68ea328fbac00681b1c2eec1eb1499005020a Mon Sep 17 00:00:00 2001
357786
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
357786
Date: Fri, 22 Jun 2018 18:59:56 +0200
357786
Subject: [PATCH 17/57] migration: introduce save_normal_page()
357786
357786
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
357786
Message-id: <20180622190005.21297-10-dgilbert@redhat.com>
357786
Patchwork-id: 81003
357786
O-Subject: [RHEL7.6 qemu-kvm-rhev PATCH 09/18] migration: introduce save_normal_page()
357786
Bugzilla: 1584139
357786
RH-Acked-by: Peter Xu <peterx@redhat.com>
357786
RH-Acked-by: Juan Quintela <quintela@redhat.com>
357786
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
357786
357786
From: Xiao Guangrong <xiaoguangrong@tencent.com>
357786
357786
It directly sends the page to the stream neither checking zero nor
357786
using xbzrle or compression
357786
357786
Reviewed-by: Peter Xu <peterx@redhat.com>
357786
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
357786
Signed-off-by: Xiao Guangrong <xiaoguangrong@tencent.com>
357786
Message-Id: <20180330075128.26919-10-xiaoguangrong@tencent.com>
357786
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
357786
(cherry picked from commit 65dacaa04fa7e6104cbcee9251c7845355769a10)
357786
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
---
357786
 migration/ram.c | 50 ++++++++++++++++++++++++++++++--------------------
357786
 1 file changed, 30 insertions(+), 20 deletions(-)
357786
357786
diff --git a/migration/ram.c b/migration/ram.c
357786
index 6e8a7e2..908879f 100644
357786
--- a/migration/ram.c
357786
+++ b/migration/ram.c
357786
@@ -1013,6 +1013,34 @@ static bool control_save_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,
357786
     return true;
357786
 }
357786
 
357786
+/*
357786
+ * directly send the page to the stream
357786
+ *
357786
+ * Returns the number of pages written.
357786
+ *
357786
+ * @rs: current RAM state
357786
+ * @block: block that contains the page we want to send
357786
+ * @offset: offset inside the block for the page
357786
+ * @buf: the page to be sent
357786
+ * @async: send to page asyncly
357786
+ */
357786
+static int save_normal_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,
357786
+                            uint8_t *buf, bool async)
357786
+{
357786
+    ram_counters.transferred += save_page_header(rs, rs->f, block,
357786
+                                                 offset | RAM_SAVE_FLAG_PAGE);
357786
+    if (async) {
357786
+        qemu_put_buffer_async(rs->f, buf, TARGET_PAGE_SIZE,
357786
+                              migrate_release_ram() &
357786
+                              migration_in_postcopy());
357786
+    } else {
357786
+        qemu_put_buffer(rs->f, buf, TARGET_PAGE_SIZE);
357786
+    }
357786
+    ram_counters.transferred += TARGET_PAGE_SIZE;
357786
+    ram_counters.normal++;
357786
+    return 1;
357786
+}
357786
+
357786
 /**
357786
  * ram_save_page: send the given page to the stream
357786
  *
357786
@@ -1053,18 +1081,7 @@ static int ram_save_page(RAMState *rs, PageSearchStatus *pss, bool last_stage)
357786
 
357786
     /* XBZRLE overflow or normal page */
357786
     if (pages == -1) {
357786
-        ram_counters.transferred +=
357786
-            save_page_header(rs, rs->f, block, offset | RAM_SAVE_FLAG_PAGE);
357786
-        if (send_async) {
357786
-            qemu_put_buffer_async(rs->f, p, TARGET_PAGE_SIZE,
357786
-                                  migrate_release_ram() &
357786
-                                  migration_in_postcopy());
357786
-        } else {
357786
-            qemu_put_buffer(rs->f, p, TARGET_PAGE_SIZE);
357786
-        }
357786
-        ram_counters.transferred += TARGET_PAGE_SIZE;
357786
-        pages = 1;
357786
-        ram_counters.normal++;
357786
+        pages = save_normal_page(rs, block, offset, p, send_async);
357786
     }
357786
 
357786
     XBZRLE_cache_unlock();
357786
@@ -1195,14 +1212,7 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss,
357786
          * we post it as normal page as compression will take much
357786
          * CPU resource.
357786
          */
357786
-        ram_counters.transferred += save_page_header(rs, rs->f, block,
357786
-                                        offset | RAM_SAVE_FLAG_PAGE);
357786
-        qemu_put_buffer_async(rs->f, p, TARGET_PAGE_SIZE,
357786
-                              migrate_release_ram() &
357786
-                              migration_in_postcopy());
357786
-        ram_counters.transferred += TARGET_PAGE_SIZE;
357786
-        ram_counters.normal++;
357786
-        pages = 1;
357786
+        pages = save_normal_page(rs, block, offset, p, true);
357786
     } else {
357786
         pages = compress_page_with_multi_thread(rs, block, offset);
357786
     }
357786
-- 
357786
1.8.3.1
357786