All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org
Cc: amit.shah@redhat.com, quintela@redhat.com
Subject: [Qemu-devel] [PATCH 1/2] Move dirty page search state into separate structure
Date: Wed, 16 Sep 2015 19:11:53 +0100	[thread overview]
Message-ID: <1442427114-5075-2-git-send-email-dgilbert@redhat.com> (raw)
In-Reply-To: <1442427114-5075-1-git-send-email-dgilbert@redhat.com>

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Pull the sarch state for one iteration of the dirty page
search into a structure.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 migration/ram.c | 54 ++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 34 insertions(+), 20 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index 7df9157..1fadf52 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -227,6 +227,17 @@ static uint64_t migration_dirty_pages;
 static uint32_t last_version;
 static bool ram_bulk_stage;
 
+/* used by the search for pages to send */
+struct PageSearchStatus {
+    /* Current block being searched */
+    RAMBlock    *block;
+    /* Current offset to search from */
+    ram_addr_t   offset;
+    /* Set once we wrap around */
+    bool         complete_round;
+};
+typdef struct PageSearchStatus PageSearchStatus;
+
 struct CompressParam {
     bool start;
     bool done;
@@ -531,7 +542,6 @@ static void migration_bitmap_sync_range(ram_addr_t start, ram_addr_t length)
         cpu_physical_memory_sync_dirty_bitmap(bitmap, start, length);
 }
 
-
 /* Fix me: there are too many global variables used in migration process. */
 static int64_t start_time;
 static int64_t bytes_xfer_prev;
@@ -923,26 +933,29 @@ static int ram_save_compressed_page(QEMUFile *f, RAMBlock *block,
 static int ram_find_and_save_block(QEMUFile *f, bool last_stage,
                                    uint64_t *bytes_transferred)
 {
-    RAMBlock *block = last_seen_block;
-    ram_addr_t offset = last_offset;
-    bool complete_round = false;
+    PageSearchStatus pss;
     int pages = 0;
 
-    if (!block)
-        block = QLIST_FIRST_RCU(&ram_list.blocks);
+    pss.block = last_seen_block;
+    pss.offset = last_offset;
+    pss.complete_round = false;
+
+    if (!pss.block)
+        pss.block = QLIST_FIRST_RCU(&ram_list.blocks);
 
     while (true) {
-        offset = migration_bitmap_find_and_reset_dirty(block, offset);
-        if (complete_round && block == last_seen_block &&
-            offset >= last_offset) {
+        pss.offset = migration_bitmap_find_and_reset_dirty(pss.block,
+                                                           pss.offset);
+        if (pss.complete_round && pss.block == last_seen_block &&
+            pss.offset >= last_offset) {
             break;
         }
-        if (offset >= block->used_length) {
-            offset = 0;
-            block = QLIST_NEXT_RCU(block, next);
-            if (!block) {
-                block = QLIST_FIRST_RCU(&ram_list.blocks);
-                complete_round = true;
+        if (pss.offset >= pss.block->used_length) {
+            pss.offset = 0;
+            pss.block = QLIST_NEXT_RCU(pss.block, next);
+            if (!pss.block) {
+                pss.block = QLIST_FIRST_RCU(&ram_list.blocks);
+                pss.complete_round = true;
                 ram_bulk_stage = false;
                 if (migrate_use_xbzrle()) {
                     /* If xbzrle is on, stop using the data compression at this
@@ -954,23 +967,24 @@ static int ram_find_and_save_block(QEMUFile *f, bool last_stage,
             }
         } else {
             if (compression_switch && migrate_use_compression()) {
-                pages = ram_save_compressed_page(f, block, offset, last_stage,
+                pages = ram_save_compressed_page(f, pss.block, pss.offset,
+                                                 last_stage,
                                                  bytes_transferred);
             } else {
-                pages = ram_save_page(f, block, offset, last_stage,
+                pages = ram_save_page(f, pss.block, pss.offset, last_stage,
                                       bytes_transferred);
             }
 
             /* if page is unmodified, continue to the next */
             if (pages > 0) {
-                last_sent_block = block;
+                last_sent_block = pss.block;
                 break;
             }
         }
     }
 
-    last_seen_block = block;
-    last_offset = offset;
+    last_seen_block = pss.block;
+    last_offset = pss.offset;
 
     return pages;
 }
-- 
2.4.3

  reply	other threads:[~2015-09-16 18:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-16 18:11 [Qemu-devel] [PATCH 0/2] Split up ram_find_and_save_block Dr. David Alan Gilbert (git)
2015-09-16 18:11 ` Dr. David Alan Gilbert (git) [this message]
2015-09-23 12:20   ` [Qemu-devel] [PATCH 1/2] Move dirty page search state into separate structure Amit Shah
2015-09-16 18:11 ` [Qemu-devel] [PATCH 2/2] ram_find_and_save_block: Split out the finding Dr. David Alan Gilbert (git)
2015-09-23 12:26   ` Amit Shah
2015-09-23 12:42     ` Dr. David Alan Gilbert

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=1442427114-5075-2-git-send-email-dgilbert@redhat.com \
    --to=dgilbert@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.