From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <lvivier@redhat.com>,
Juan Quintela <quintela@redhat.com>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
peterx@redhat.com
Subject: [Qemu-devel] [PATCH 4/4] migration: new ram_init_bitmaps()
Date: Thu, 19 Oct 2017 14:32:00 +0800 [thread overview]
Message-ID: <20171019063200.19048-5-peterx@redhat.com> (raw)
In-Reply-To: <20171019063200.19048-1-peterx@redhat.com>
Rearrange the bitmap initialization and the first sync. Since at it,
make sure the locks are taken/released in correct order (I moved RCU
unlock upper - though it may not affect much).
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/ram.c | 51 ++++++++++++++++++++++++++++++---------------------
1 file changed, 30 insertions(+), 21 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index 3df7715d63..0d24fc12f4 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2099,30 +2099,15 @@ static int ram_state_init(RAMState **rsp)
return 0;
}
-static int ram_init_all(RAMState **rsp)
+static void ram_list_init_bitmaps(void)
{
- if (ram_state_init(rsp)) {
- return -1;
- }
-
- if (xbzrle_init()) {
- ram_state_cleanup(rsp);
- return -1;
- }
-
- /* For memory_global_dirty_log_start below. */
- qemu_mutex_lock_iothread();
-
- qemu_mutex_lock_ramlist();
- rcu_read_lock();
+ RAMBlock *block;
+ unsigned long pages;
/* Skip setting bitmap if there is no RAM */
if (ram_bytes_total()) {
- RAMBlock *block;
-
QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
- unsigned long pages = block->max_length >> TARGET_PAGE_BITS;
-
+ pages = block->max_length >> TARGET_PAGE_BITS;
block->bmap = bitmap_new(pages);
bitmap_set(block->bmap, 0, pages);
if (migrate_postcopy_ram()) {
@@ -2131,12 +2116,36 @@ static int ram_init_all(RAMState **rsp)
}
}
}
+}
+
+static void ram_init_bitmaps(RAMState *rs)
+{
+ /* For memory_global_dirty_log_start below. */
+ qemu_mutex_lock_iothread();
+ qemu_mutex_lock_ramlist();
+ rcu_read_lock();
+ ram_list_init_bitmaps();
memory_global_dirty_log_start();
- migration_bitmap_sync(*rsp);
+ migration_bitmap_sync(rs);
+
+ rcu_read_unlock();
qemu_mutex_unlock_ramlist();
qemu_mutex_unlock_iothread();
- rcu_read_unlock();
+}
+
+static int ram_init_all(RAMState **rsp)
+{
+ if (ram_state_init(rsp)) {
+ return -1;
+ }
+
+ if (xbzrle_init()) {
+ ram_state_cleanup(rsp);
+ return -1;
+ }
+
+ ram_init_bitmaps(*rsp);
return 0;
}
--
2.13.5
next prev parent reply other threads:[~2017-10-19 6:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-19 6:31 [Qemu-devel] [PATCH 0/4] migration: fixes and cleanups for ram state init Peter Xu
2017-10-19 6:31 ` [Qemu-devel] [PATCH 1/4] migration: provide ram_state_init() Peter Xu
2017-10-23 11:18 ` Juan Quintela
2017-10-19 6:31 ` [Qemu-devel] [PATCH 2/4] migration: provide ram_state_cleanup Peter Xu
2017-10-23 11:19 ` Juan Quintela
2017-10-19 6:31 ` [Qemu-devel] [PATCH 3/4] migration: clean up xbzrle cache init/destroy Peter Xu
2017-10-23 11:20 ` Juan Quintela
2017-10-19 6:32 ` Peter Xu [this message]
2017-10-23 11:38 ` [Qemu-devel] [PATCH 4/4] migration: new ram_init_bitmaps() 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=20171019063200.19048-5-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=dgilbert@redhat.com \
--cc=lvivier@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 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).