qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Cc: liang.z.li@intel.com
Subject: [Qemu-devel] [PATCH 5/6] save_block_hdr: we can recalculate the cont parameter here
Date: Thu, 12 Feb 2015 23:03:10 +0100	[thread overview]
Message-ID: <1423778591-12590-6-git-send-email-quintela@redhat.com> (raw)
In-Reply-To: <1423778591-12590-1-git-send-email-quintela@redhat.com>

No need to pass it through all the callers.  Once there, update
last_sent_block here.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 arch_init.c | 47 ++++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 23 deletions(-)

diff --git a/arch_init.c b/arch_init.c
index 834f40c..95a61e2 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -304,34 +304,39 @@ uint64_t xbzrle_mig_pages_overflow(void)
     return acct_info.xbzrle_overflows;
 }

+/* This is the last block that we have visited serching for dirty pages
+ */
+static RAMBlock *last_seen_block;
+/* This is the last block from where we have sent data */
+static RAMBlock *last_sent_block;
+static ram_addr_t last_offset;
+static unsigned long *migration_bitmap;
+static uint64_t migration_dirty_pages;
+static uint32_t last_version;
+static bool ram_bulk_stage;
+
 static size_t save_block_hdr(QEMUFile *f, RAMBlock *block, ram_addr_t offset,
-                             int cont, int flag)
+                             int flag)
 {
     size_t size;

-    qemu_put_be64(f, offset | cont | flag);
+    if (block == last_sent_block) {
+        offset |= RAM_SAVE_FLAG_CONTINUE;
+    }
+
+    qemu_put_be64(f, offset | flag);
     size = 8;

-    if (!cont) {
+    if (block != last_sent_block) {
         qemu_put_byte(f, strlen(block->idstr));
         qemu_put_buffer(f, (uint8_t *)block->idstr,
                         strlen(block->idstr));
         size += 1 + strlen(block->idstr);
+        last_sent_block = block;
     }
     return size;
 }

-/* This is the last block that we have visited serching for dirty pages
- */
-static RAMBlock *last_seen_block;
-/* This is the last block from where we have sent data */
-static RAMBlock *last_sent_block;
-static ram_addr_t last_offset;
-static unsigned long *migration_bitmap;
-static uint64_t migration_dirty_pages;
-static uint32_t last_version;
-static bool ram_bulk_stage;
-
 /* Update the xbzrle cache to reflect a page that's been sent as all 0.
  * The important thing is that a stale (not-yet-0'd) page be replaced
  * by the new data.
@@ -369,7 +374,7 @@ static void xbzrle_cache_zero_page(ram_addr_t current_addr)
  */
 static int save_xbzrle_page(QEMUFile *f, uint8_t **current_data,
                             ram_addr_t current_addr, RAMBlock *block,
-                            ram_addr_t offset, int cont, bool last_stage,
+                            ram_addr_t offset, bool last_stage,
                             uint64_t *bytes_transferred)
 {
     int encoded_len = 0, bytes_xbzrle;
@@ -419,7 +424,7 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t **current_data,
     }

     /* Send XBZRLE based compressed page */
-    bytes_xbzrle = save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_XBZRLE);
+    bytes_xbzrle = save_block_hdr(f, block, offset, RAM_SAVE_FLAG_XBZRLE);
     qemu_put_byte(f, ENCODING_FLAG_XBZRLE);
     qemu_put_be16(f, encoded_len);
     qemu_put_buffer(f, XBZRLE.encoded_buf, encoded_len);
@@ -604,15 +609,12 @@ static int ram_save_page(QEMUFile *f, RAMBlock* block, ram_addr_t offset,
 {
     int pages = -1;
     uint64_t bytes_xmit;
-    int cont;
     ram_addr_t current_addr;
     MemoryRegion *mr = block->mr;
     uint8_t *p;
     int ret;
     bool send_async = true;

-    cont = (block == last_sent_block) ? RAM_SAVE_FLAG_CONTINUE : 0;
-
     p = memory_region_get_ram_ptr(mr) + offset;

     /* In doubt sent page as normal */
@@ -637,7 +639,7 @@ static int ram_save_page(QEMUFile *f, RAMBlock* block, ram_addr_t offset,
         }
     } else if (is_zero_range(p, TARGET_PAGE_SIZE)) {
         acct_info.dup_pages++;
-        *bytes_transferred += save_block_hdr(f, block, offset, cont,
+        *bytes_transferred += save_block_hdr(f, block, offset,
                                              RAM_SAVE_FLAG_COMPRESS);
         qemu_put_byte(f, 0);
         *bytes_transferred += 1;
@@ -648,7 +650,7 @@ static int ram_save_page(QEMUFile *f, RAMBlock* block, ram_addr_t offset,
         xbzrle_cache_zero_page(current_addr);
     } else if (!ram_bulk_stage && migrate_use_xbzrle()) {
         pages = save_xbzrle_page(f, &p, current_addr, block,
-                                 offset, cont, last_stage, bytes_transferred);
+                                 offset, last_stage, bytes_transferred);
         if (!last_stage) {
             /* Can't send this cached data async, since the cache page
              * might get updated before it gets to the wire
@@ -659,7 +661,7 @@ static int ram_save_page(QEMUFile *f, RAMBlock* block, ram_addr_t offset,

     /* XBZRLE overflow or normal page */
     if (pages == -1) {
-        *bytes_transferred += save_block_hdr(f, block, offset, cont,
+        *bytes_transferred += save_block_hdr(f, block, offset,
                                              RAM_SAVE_FLAG_PAGE);
         if (send_async) {
             qemu_put_buffer_async(f, p, TARGET_PAGE_SIZE);
@@ -720,7 +722,6 @@ static int ram_find_and_save_block(QEMUFile *f, bool last_stage,

             /* if page is unmodified, continue to the next */
             if (pages > 0) {
-                last_sent_block = block;
                 break;
             }
         }
-- 
2.1.0

  parent reply	other threads:[~2015-02-12 22:03 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-12 22:03 [Qemu-devel] [PATCH 0/6] migration: differentiate between pages and bytes Juan Quintela
2015-02-12 22:03 ` [Qemu-devel] [PATCH 1/6] ram: make all save_page functions take a uint64_t parameter Juan Quintela
2015-02-24  9:53   ` Amit Shah
2015-02-12 22:03 ` [Qemu-devel] [PATCH 2/6] ram_find_and_save_block: change calling convention Juan Quintela
2015-02-24 10:05   ` Amit Shah
2015-02-12 22:03 ` [Qemu-devel] [PATCH 3/6] ram_save_page: change calling covention Juan Quintela
2015-02-12 22:03 ` [Qemu-devel] [PATCH 4/6] save_xbzrle_page: change calling convention Juan Quintela
2015-02-24 10:37   ` Amit Shah
2015-03-12 15:48     ` Juan Quintela
2015-02-12 22:03 ` Juan Quintela [this message]
2015-02-26  4:49   ` [Qemu-devel] [PATCH 5/6] save_block_hdr: we can recalculate the cont parameter here Li, Liang Z
2015-03-12 15:36     ` Juan Quintela
2015-02-12 22:03 ` [Qemu-devel] [PATCH 6/6] rename save_block_hdr to save_page_header Juan Quintela
2015-02-24 12:48   ` Amit Shah
2015-02-26  4:53     ` Li, Liang Z
2015-03-12 15:44     ` Juan Quintela
2015-02-13  2:28 ` [Qemu-devel] [PATCH 0/6] migration: differentiate between pages and bytes Li, Liang Z
2015-02-17 14:23 ` Dr. David Alan Gilbert
2015-02-26  5:15   ` Li, Liang Z
2015-02-26  9:59     ` Dr. David Alan Gilbert
2015-02-26  7:05 ` Alex Bennée
2015-03-12 15:33   ` Juan Quintela
2015-03-09  2:02 ` Li, Liang Z
2015-03-12 15:33   ` Juan Quintela

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=1423778591-12590-6-git-send-email-quintela@redhat.com \
    --to=quintela@redhat.com \
    --cc=liang.z.li@intel.com \
    --cc=qemu-devel@nongnu.org \
    /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).