From: Jitendra Kolhe <jitendra.kolhe@hpe.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, crosthwaite.peter@gmail.com,
rth@twiddle.net, eblake@redhat.com, lcapitulino@redhat.com,
stefanha@redhat.com, armbru@redhat.com, quintela@redhat.com,
mst@redhat.com, den@openvz.org, JBottomley@Odin.com,
borntraeger@de.ibm.com, amit.shah@redhat.com,
dgilbert@redhat.com, ehabkost@redhat.com, jitendra.kolhe@hpe.com,
mohan_parthasarathy@hpe.com, simhan@hpe.com,
renganathan.meenakshisundaram@hpe.com
Subject: [Qemu-devel] [PATCH v3 4/4] migration: skip scanning and migrating ram pages released by virtio-balloon driver.
Date: Wed, 18 May 2016 16:52:12 +0530 [thread overview]
Message-ID: <1463570532-29862-1-git-send-email-jitendra.kolhe@hpe.com> (raw)
During live migration, byte offset within memory region of the start of
a dirty page is checked against the balloon bitmap, if the bit is set in
the balloon bitmap, the corresponding ram page will be excluded from
scanning and sending header information during migration. In case
TARGET_PAGE_BITS > VIRTIO_BALLOON_PFN_SHIFT, the bitmap test function will
return true if all sub-pages of size (1UL << VIRTIO_BALLOON_PFN_SHIFT)
within dirty page are ballooned out.
The test against bitmap gets disabled in case balloon bitmap status is set
to disable during migration setup.
Signed-off-by: Jitendra Kolhe <jitendra.kolhe@hpe.com>
---
balloon.c | 34 ++++++++++++++++++++++++++++++++++
include/sysemu/balloon.h | 1 +
migration/ram.c | 6 +++++-
3 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/balloon.c b/balloon.c
index 494b8aa..baa7e5a 100644
--- a/balloon.c
+++ b/balloon.c
@@ -274,3 +274,37 @@ void qemu_balloon_bitmap_reset(bool source)
}
balloon_bitmap_state = BALLOON_BITMAP_INIT;
}
+
+int qemu_balloon_bitmap_test(RAMBlock *rb, ram_addr_t addr)
+{
+ ram_addr_t base;
+ unsigned long nr = 0;
+ int i = 0, count = 0, loop = 0;
+ int ret = 0;
+
+ if (balloon_bitmap_state != BALLOON_BITMAP_ENABLE) {
+ return 0;
+ }
+
+ base = rb->offset >> balloon_bitmap_pfn_shift;
+ nr = base + (addr >> balloon_bitmap_pfn_shift);
+
+ qemu_mutex_lock_balloon_bitmap();
+ if (TARGET_PAGE_BITS <= balloon_bitmap_pfn_shift) {
+ ret = (test_bit(nr, bmap)) ? 1 : 0;
+ } else {
+ loop = (1UL << (TARGET_PAGE_BITS - balloon_bitmap_pfn_shift));
+ for (i = 0; i < loop; i++) {
+ if (test_bit((nr + i), bmap)) {
+ count++;
+ }
+ }
+ /* addr is alligned to TARGET_PAGE_SIZE, return true only if all
+ * sub-pages (1 << balloon_bitmap_pfn_shift or 4K) are ballooned out.
+ */
+ ret = (count == loop) ? 1 : 0;
+ }
+ qemu_mutex_unlock_balloon_bitmap();
+
+ return ret;
+}
diff --git a/include/sysemu/balloon.h b/include/sysemu/balloon.h
index 9a9bed9..941982e 100644
--- a/include/sysemu/balloon.h
+++ b/include/sysemu/balloon.h
@@ -34,5 +34,6 @@ void qemu_balloon_bitmap_extend(RAMBlock *new_block,
ram_addr_t old, ram_addr_t new);
void qemu_balloon_bitmap_setup(void);
void qemu_balloon_bitmap_reset(bool source);
+int qemu_balloon_bitmap_test(RAMBlock *rb, ram_addr_t addr);
#endif
diff --git a/migration/ram.c b/migration/ram.c
index a4c3582..a5802d9 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -704,6 +704,10 @@ static int save_zero_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset,
{
int pages = -1;
+ if (qemu_balloon_bitmap_test(block, offset) == 1) {
+ return 0; /* pages */
+ }
+
if (is_zero_range(p, TARGET_PAGE_SIZE)) {
acct_info.dup_pages++;
*bytes_transferred += save_page_header(f, block,
@@ -770,7 +774,7 @@ static int ram_save_page(QEMUFile *f, PageSearchStatus *pss,
}
} else {
pages = save_zero_page(f, block, offset, p, bytes_transferred);
- if (pages > 0) {
+ if (pages >= 0) {
/* Must let xbzrle know, otherwise a previous (now 0'd) cached
* page would be stale
*/
--
1.8.3.1
next reply other threads:[~2016-05-18 11:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-18 11:22 Jitendra Kolhe [this message]
-- strict thread matches above, loose matches on Subject: below --
2016-05-18 11:28 [Qemu-devel] [PATCH v3 4/4] migration: skip scanning and migrating ram pages released by virtio-balloon driver Jitendra Kolhe
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=1463570532-29862-1-git-send-email-jitendra.kolhe@hpe.com \
--to=jitendra.kolhe@hpe.com \
--cc=JBottomley@Odin.com \
--cc=amit.shah@redhat.com \
--cc=armbru@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=crosthwaite.peter@gmail.com \
--cc=den@openvz.org \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=ehabkost@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mohan_parthasarathy@hpe.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=renganathan.meenakshisundaram@hpe.com \
--cc=rth@twiddle.net \
--cc=simhan@hpe.com \
--cc=stefanha@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).