qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] migration: Don't sync dirty bitmap when init
@ 2021-08-17 18:06 Peter Xu
  0 siblings, 0 replies; only message in thread
From: Peter Xu @ 2021-08-17 18:06 UTC (permalink / raw)
  To: qemu-devel
  Cc: Leonardo Bras Soares Passos, Juan Quintela,
	Dr . David Alan Gilbert, peterx, David Hildenbrand

Drop migration_bitmap_sync_precopy() since dirty bitmap is initialized to all
ones anyways, so no need to sync at start.

Since at it, clean the locks up a bit:

  - RCU lock is only needed to walk the ramblocks, move it into
    ram_list_init_bitmaps().

  - The ram_list lock seems to be unnecessary now, drop it.

  - The bql should only be needed for memory_global_dirty_log_start(), move it
    to only protect that.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 migration/ram.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index 7a43bfd7af..189d6427ac 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2651,6 +2651,7 @@ static void ram_list_init_bitmaps(void)
             shift = CLEAR_BITMAP_SHIFT_MIN;
         }
 
+        RCU_READ_LOCK_GUARD();
         RAMBLOCK_FOREACH_NOT_IGNORED(block) {
             pages = block->max_length >> TARGET_PAGE_BITS;
             /*
@@ -2672,20 +2673,14 @@ static void ram_list_init_bitmaps(void)
 
 static void ram_init_bitmaps(RAMState *rs)
 {
-    /* For memory_global_dirty_log_start below.  */
-    qemu_mutex_lock_iothread();
-    qemu_mutex_lock_ramlist();
+    ram_list_init_bitmaps();
 
-    WITH_RCU_READ_LOCK_GUARD() {
-        ram_list_init_bitmaps();
-        /* We don't use dirty log with background snapshots */
-        if (!migrate_background_snapshot()) {
-            memory_global_dirty_log_start();
-            migration_bitmap_sync_precopy(rs);
-        }
+    /* We don't use dirty log with background snapshots */
+    if (!migrate_background_snapshot()) {
+        qemu_mutex_lock_iothread();
+        memory_global_dirty_log_start();
+        qemu_mutex_unlock_iothread();
     }
-    qemu_mutex_unlock_ramlist();
-    qemu_mutex_unlock_iothread();
 }
 
 static int ram_init_all(RAMState **rsp)
-- 
2.31.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-17 18:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-17 18:06 [PATCH] migration: Don't sync dirty bitmap when init Peter Xu

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).