From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Wei Wang <wei.w.wang@intel.com>
Cc: qemu-devel@nongnu.org, mst@redhat.com, quintela@redhat.com,
pbonzini@redhat.com, liliang.opensource@gmail.com,
yang.zhang.wz@gmail.com, quan.xu0@gmail.com, nilal@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 2/3] migration: use the free page reporting feature from balloon
Date: Fri, 9 Feb 2018 11:50:21 +0000 [thread overview]
Message-ID: <20180209115021.GB2428@work-vm> (raw)
In-Reply-To: <1517915299-15349-3-git-send-email-wei.w.wang@intel.com>
* Wei Wang (wei.w.wang@intel.com) wrote:
> Use the free page reporting feature from the balloon device to clear the
> bits corresponding to guest free pages from the dirty bitmap, so that the
> free memory are not sent.
>
> Signed-off-by: Wei Wang <wei.w.wang@intel.com>
> CC: Michael S. Tsirkin <mst@redhat.com>
> CC: Juan Quintela <quintela@redhat.com>
> ---
> migration/ram.c | 24 ++++++++++++++++++++----
> 1 file changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/migration/ram.c b/migration/ram.c
> index d6f462c..4fe16d2 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -49,6 +49,7 @@
> #include "qemu/rcu_queue.h"
> #include "migration/colo.h"
> #include "migration/block.h"
> +#include "sysemu/balloon.h"
>
> /***********************************************************/
> /* ram save/restore */
> @@ -206,6 +207,10 @@ struct RAMState {
> uint32_t last_version;
> /* We are in the first round */
> bool ram_bulk_stage;
> + /* The feature, skipping the transfer of free pages, is supported */
> + bool free_page_support;
> + /* Skip the transfer of free pages in the bulk stage */
> + bool free_page_done;
> /* How many times we have dirty too many pages */
> int dirty_rate_high_cnt;
> /* these variables are used for bitmap sync */
> @@ -773,7 +778,7 @@ unsigned long migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb,
> unsigned long *bitmap = rb->bmap;
> unsigned long next;
>
> - if (rs->ram_bulk_stage && start > 0) {
> + if (rs->ram_bulk_stage && start > 0 && !rs->free_page_support) {
> next = start + 1;
> } else {
> next = find_next_bit(bitmap, size, start);
> @@ -1653,6 +1658,8 @@ static void ram_state_reset(RAMState *rs)
> rs->last_page = 0;
> rs->last_version = ram_list.version;
> rs->ram_bulk_stage = true;
> + rs->free_page_support = balloon_free_page_support();
> + rs->free_page_done = false;
> }
>
> #define MAX_WAIT 50 /* ms, half buffered_file limit */
> @@ -2135,7 +2142,7 @@ static int ram_state_init(RAMState **rsp)
> return 0;
> }
>
> -static void ram_list_init_bitmaps(void)
> +static void ram_list_init_bitmaps(RAMState *rs)
> {
> RAMBlock *block;
> unsigned long pages;
> @@ -2145,7 +2152,11 @@ static void ram_list_init_bitmaps(void)
> QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
> pages = block->max_length >> TARGET_PAGE_BITS;
> block->bmap = bitmap_new(pages);
> - bitmap_set(block->bmap, 0, pages);
> + if (rs->free_page_support) {
> + bitmap_set(block->bmap, 1, pages);
I don't understand how it makes sense to do that here;
ignoring anything ese it means that migration_dirty_pages is wrong
which could end up with migration finishing before all real pages are
sent.
Dave
> + } else {
> + bitmap_set(block->bmap, 0, pages);
> + }
> if (migrate_postcopy_ram()) {
> block->unsentmap = bitmap_new(pages);
> bitmap_set(block->unsentmap, 0, pages);
> @@ -2161,7 +2172,7 @@ static void ram_init_bitmaps(RAMState *rs)
> qemu_mutex_lock_ramlist();
> rcu_read_lock();
>
> - ram_list_init_bitmaps();
> + ram_list_init_bitmaps(rs);
> memory_global_dirty_log_start();
> migration_bitmap_sync(rs);
>
> @@ -2275,6 +2286,11 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
>
> ram_control_before_iterate(f, RAM_CONTROL_ROUND);
>
> + if (rs->free_page_support && !rs->free_page_done) {
> + balloon_free_page_poll();
> + rs->free_page_done = true;
> + }
> +
> t0 = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
> i = 0;
> while ((ret = qemu_file_rate_limit(f)) == 0) {
> --
> 1.8.3.1
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2018-02-09 11:50 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-06 11:08 [Qemu-devel] [PATCH v2 0/3] virtio-balloon: free page hint reporting support Wei Wang
2018-02-06 11:08 ` [Qemu-devel] [PATCH v2 1/3] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT Wei Wang
2018-02-07 1:04 ` Michael S. Tsirkin
2018-03-02 9:32 ` Wei Wang
2018-02-09 12:06 ` Dr. David Alan Gilbert
2018-02-06 11:08 ` [Qemu-devel] [PATCH v2 2/3] migration: use the free page reporting feature from balloon Wei Wang
2018-02-06 23:57 ` Michael S. Tsirkin
2018-02-08 3:54 ` Wei Wang
2018-02-09 11:50 ` Dr. David Alan Gilbert [this message]
2018-02-26 5:07 ` Wei Wang
2018-02-26 9:22 ` Wang, Wei W
2018-02-06 11:08 ` [Qemu-devel] [PATCH v2 3/3] virtio-balloon: add a timer to limit the free page report waiting time Wei Wang
2018-02-06 23:43 ` Michael S. Tsirkin
2018-02-09 12:15 ` Dr. David Alan Gilbert
2018-02-26 4:35 ` Wei Wang
2018-02-27 0:50 ` Michael S. Tsirkin
2018-02-27 10:10 ` Wei Wang
2018-02-27 13:08 ` Liang Li
2018-02-28 10:33 ` Wei Wang
2018-02-27 10:34 ` Dr. David Alan Gilbert
2018-02-28 10:37 ` Wei Wang
2018-02-07 0:02 ` [Qemu-devel] [PATCH v2 0/3] virtio-balloon: free page hint reporting support Michael S. Tsirkin
2018-02-08 5:38 ` Wei Wang
2018-02-08 20:15 ` Dr. David Alan Gilbert
2018-02-09 3:10 ` Wei Wang
2018-02-09 10:53 ` Dr. David Alan Gilbert
2018-02-26 4:42 ` Wei Wang
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=20180209115021.GB2428@work-vm \
--to=dgilbert@redhat.com \
--cc=liliang.opensource@gmail.com \
--cc=mst@redhat.com \
--cc=nilal@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quan.xu0@gmail.com \
--cc=quintela@redhat.com \
--cc=wei.w.wang@intel.com \
--cc=yang.zhang.wz@gmail.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).