From: Quan Xu <quan.xu0@gmail.com>
To: kvm <kvm@vger.kernel.org>, qemu-devel@nongnu.org
Cc: quintela@redhat.com, "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: [Qemu-devel] Subject: [RFC PATCH v2] migration: calculate remaining pages accurately during the bulk stage
Date: Wed, 5 Sep 2018 22:17:01 +0800 [thread overview]
Message-ID: <c9da5617-ddd8-d122-20c4-79b0bd92c176@gmail.com> (raw)
From 7de4cc7c944bfccde0ef10992a7ec882fdcf0508 Mon Sep 17 00:00:00 2001
From: Quan Xu <quan.xu0@gmail.com>
Date: Wed, 5 Sep 2018 22:06:58 +0800
Subject: [RFC PATCH v2] migration: calculate remaining pages accurately
during the bulk stage
Since the bulk stage assumes in (migration_bitmap_find_dirty) that every
page is dirty, initialize the number of dirty pages at the beggining of
the iteration and then decrease it for each processed page.
Signed-off-by: Quan Xu <quan.xu0@gmail.com>
---
migration/ram.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/migration/ram.c b/migration/ram.c
index 79c8942..1a11436 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -290,6 +290,8 @@ struct RAMState {
uint32_t last_version;
/* We are in the first round */
bool ram_bulk_stage;
+ /* Remaining bytes in the first round */
+ uint64_t ram_bulk_bytes;
/* How many times we have dirty too many pages */
int dirty_rate_high_cnt;
/* these variables are used for bitmap sync */
@@ -1540,6 +1542,7 @@ unsigned long migration_bitmap_find_dirty(RAMState
*rs, RAMBlock *rb,
if (rs->ram_bulk_stage && start > 0) {
next = start + 1;
+ rs->ram_bulk_bytes -= TARGET_PAGE_SIZE;
} else {
next = find_next_bit(bitmap, size, start);
}
@@ -2001,6 +2004,7 @@ static bool find_dirty_block(RAMState *rs,
PageSearchStatus *pss, bool *again)
/* Flag that we've looped */
pss->complete_round = true;
rs->ram_bulk_stage = false;
+ rs->ram_bulk_bytes = 0;
if (migrate_use_xbzrle()) {
/* If xbzrle is on, stop using the data compression at
this
* point. In theory, xbzrle can do better than
compression.
@@ -2513,6 +2517,7 @@ static void ram_state_reset(RAMState *rs)
rs->last_page = 0;
rs->last_version = ram_list.version;
rs->ram_bulk_stage = true;
+ rs->ram_bulk_bytes = ram_bytes_total();
}
#define MAX_WAIT 50 /* ms, half buffered_file limit */
@@ -3308,7 +3313,7 @@ static void ram_save_pending(QEMUFile *f, void
*opaque, uint64_t max_size,
/* We can do postcopy, and all the data is postcopiable */
*res_compatible += remaining_size;
} else {
- *res_precopy_only += remaining_size;
+ *res_precopy_only += remaining_size + rs->ram_bulk_bytes;
}
}
--
1.8.3.1
next reply other threads:[~2018-09-05 14:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-05 14:17 Quan Xu [this message]
2018-09-05 16:42 ` [Qemu-devel] Subject: [RFC PATCH v2] migration: calculate remaining pages accurately during the bulk stage Eric Blake
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=c9da5617-ddd8-d122-20c4-79b0bd92c176@gmail.com \
--to=quan.xu0@gmail.com \
--cc=dgilbert@redhat.com \
--cc=kvm@vger.kernel.org \
--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 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).