qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org, quintela@redhat.com, peterx@redhat.com,
	a.perevalov@samsung.com, xiaoguangrong@tencent.com
Subject: [Qemu-devel] [PULL 12/16] migration: move some code to ram_save_host_page
Date: Wed, 25 Apr 2018 21:03:22 +0100	[thread overview]
Message-ID: <20180425200326.72337-13-dgilbert@redhat.com> (raw)
In-Reply-To: <20180425200326.72337-1-dgilbert@redhat.com>

From: Xiao Guangrong <xiaoguangrong@tencent.com>

Move some code from ram_save_target_page() to ram_save_host_page()
to make it be more readable for latter patches that dramatically
clean ram_save_target_page() up

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Xiao Guangrong <xiaoguangrong@tencent.com>
Message-Id: <20180330075128.26919-7-xiaoguangrong@tencent.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 migration/ram.c | 43 +++++++++++++++++++------------------------
 1 file changed, 19 insertions(+), 24 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index 79c7958993..c3628b020e 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1483,38 +1483,23 @@ err:
  * Returns the number of pages written
  *
  * @rs: current RAM state
- * @ms: current migration state
  * @pss: data about the page we want to send
  * @last_stage: if we are at the completion stage
  */
 static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss,
                                 bool last_stage)
 {
-    int res = 0;
-
-    /* Check the pages is dirty and if it is send it */
-    if (migration_bitmap_clear_dirty(rs, pss->block, pss->page)) {
-        /*
-         * If xbzrle is on, stop using the data compression after first
-         * round of migration even if compression is enabled. In theory,
-         * xbzrle can do better than compression.
-         */
-        if (migrate_use_compression() &&
-            (rs->ram_bulk_stage || !migrate_use_xbzrle())) {
-            res = ram_save_compressed_page(rs, pss, last_stage);
-        } else {
-            res = ram_save_page(rs, pss, last_stage);
-        }
-
-        if (res < 0) {
-            return res;
-        }
-        if (pss->block->unsentmap) {
-            clear_bit(pss->page, pss->block->unsentmap);
-        }
+    /*
+     * If xbzrle is on, stop using the data compression after first
+     * round of migration even if compression is enabled. In theory,
+     * xbzrle can do better than compression.
+     */
+    if (migrate_use_compression() &&
+        (rs->ram_bulk_stage || !migrate_use_xbzrle())) {
+        return ram_save_compressed_page(rs, pss, last_stage);
     }
 
-    return res;
+    return ram_save_page(rs, pss, last_stage);
 }
 
 /**
@@ -1543,12 +1528,22 @@ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss,
         qemu_ram_pagesize(pss->block) >> TARGET_PAGE_BITS;
 
     do {
+        /* Check the pages is dirty and if it is send it */
+        if (!migration_bitmap_clear_dirty(rs, pss->block, pss->page)) {
+            pss->page++;
+            continue;
+        }
+
         tmppages = ram_save_target_page(rs, pss, last_stage);
         if (tmppages < 0) {
             return tmppages;
         }
 
         pages += tmppages;
+        if (pss->block->unsentmap) {
+            clear_bit(pss->page, pss->block->unsentmap);
+        }
+
         pss->page++;
     } while ((pss->page & (pagesize_bits - 1)) &&
              offset_in_ramblock(pss->block, pss->page << TARGET_PAGE_BITS));
-- 
2.17.0

  parent reply	other threads:[~2018-04-25 20:03 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-25 20:03 [Qemu-devel] [PULL 00/16] migration queue Dr. David Alan Gilbert (git)
2018-04-25 20:03 ` [Qemu-devel] [PULL 01/16] migration: introduce postcopy-blocktime capability Dr. David Alan Gilbert (git)
2018-04-25 20:34   ` Eric Blake
2018-04-26 12:24     ` Dr. David Alan Gilbert
2018-04-25 20:03 ` [Qemu-devel] [PULL 02/16] migration: add postcopy blocktime ctx into MigrationIncomingState Dr. David Alan Gilbert (git)
2018-04-25 20:03 ` [Qemu-devel] [PULL 03/16] migration: calculate vCPU blocktime on dst side Dr. David Alan Gilbert (git)
2018-04-25 20:03 ` [Qemu-devel] [PULL 04/16] migration: postcopy_blocktime documentation Dr. David Alan Gilbert (git)
2018-04-25 20:03 ` [Qemu-devel] [PULL 05/16] migration: add blocktime calculation into migration-test Dr. David Alan Gilbert (git)
2018-04-25 20:03 ` [Qemu-devel] [PULL 06/16] migration: add postcopy total blocktime into query-migrate Dr. David Alan Gilbert (git)
2018-04-25 20:37   ` Eric Blake
2018-04-26 12:28     ` Dr. David Alan Gilbert
2018-04-25 20:03 ` [Qemu-devel] [PULL 07/16] migration: stop compressing page in migration thread Dr. David Alan Gilbert (git)
2018-04-25 20:03 ` [Qemu-devel] [PULL 08/16] migration: stop compression to allocate and free memory frequently Dr. David Alan Gilbert (git)
2018-04-25 20:03 ` [Qemu-devel] [PULL 09/16] migration: stop decompression " Dr. David Alan Gilbert (git)
2018-04-25 20:03 ` [Qemu-devel] [PULL 10/16] migration: detect compression and decompression errors Dr. David Alan Gilbert (git)
2018-04-25 20:03 ` [Qemu-devel] [PULL 11/16] migration: introduce control_save_page() Dr. David Alan Gilbert (git)
2018-04-25 20:03 ` Dr. David Alan Gilbert (git) [this message]
2018-04-25 20:03 ` [Qemu-devel] [PULL 13/16] migration: move calling control_save_page to the common place Dr. David Alan Gilbert (git)
2018-04-25 20:03 ` [Qemu-devel] [PULL 14/16] migration: move calling save_zero_page " Dr. David Alan Gilbert (git)
2018-04-25 20:03 ` [Qemu-devel] [PULL 15/16] migration: introduce save_normal_page() Dr. David Alan Gilbert (git)
2018-04-25 20:03 ` [Qemu-devel] [PULL 16/16] migration: remove ram_save_compressed_page() Dr. David Alan Gilbert (git)
2018-04-26 10:57 ` [Qemu-devel] [PULL 00/16] migration queue Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180425200326.72337-13-dgilbert@redhat.com \
    --to=dgilbert@redhat.com \
    --cc=a.perevalov@samsung.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=xiaoguangrong@tencent.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).