qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: Leonardo Bras Soares Passos <lsoaresp@redhat.com>,
	Juan Quintela <quintela@redhat.com>,
	"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
	peterx@redhat.com, David Hildenbrand <david@redhat.com>
Subject: [PATCH] migration: Don't sync dirty bitmap when init
Date: Tue, 17 Aug 2021 14:06:29 -0400	[thread overview]
Message-ID: <20210817180629.55126-1-peterx@redhat.com> (raw)

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



                 reply	other threads:[~2021-08-17 18:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210817180629.55126-1-peterx@redhat.com \
    --to=peterx@redhat.com \
    --cc=david@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=lsoaresp@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).