All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org, Avi Kivity <avi@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 02/41] fix migration sync
Date: Tue, 25 Sep 2012 10:45:44 +0200	[thread overview]
Message-ID: <50616F38.1000201@redhat.com> (raw)
In-Reply-To: <505C5AD0.1080903@redhat.com>

Il 21/09/2012 14:17, Paolo Bonzini ha scritto:
> 
> -    QLIST_FOREACH(block, &ram_list.blocks, next) {
> -        for (addr = 0; addr < block->length; addr += TARGET_PAGE_SIZE) {
> -            if (!memory_region_get_dirty(block->mr, addr, TARGET_PAGE_SIZE,
> -                                         DIRTY_MEMORY_MIGRATION)) {
> -                memory_region_set_dirty(block->mr, addr, TARGET_PAGE_SIZE);
> -            }
> -        }
> -    }
> -
>      memory_global_dirty_log_start();
> +    memory_global_sync_dirty_bitmap(get_system_memory());

Hmm, perhaps for KVM but probably not for TCG.  But this looks like a bug in
KVM, maybe a fix there would be better?

diff --git a/kvm-all.c b/kvm-all.c
index 78e7a88..fdab4f6 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -744,6 +746,8 @@ static void kvm_log_global_start(struct MemoryListener *listener)
 {
     int r;
 
+    /* Clear the KVM bitmap.  */
+    kvm_physical_sync_dirty_bitmap(section);
     r = kvm_set_migration_log(1);
     assert(r >= 0);
 }

On the other hand, you're doing useless work syncing the KVM bitmap to the
TCG one---even though the TCG bitmap is all-ones!  Something like this ought
to be faster, but I'm not sure whether it is conceptually right:

diff --git a/kvm-all.c b/kvm-all.c
index 78e7a88..fdab4f6 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -399,7 +399,7 @@ static int kvm_get_dirty_pages_log_range(MemoryRegionSection *section,
  * @start_add: start of logged region.
  * @end_addr: end of logged region.
  */
-static int kvm_physical_sync_dirty_bitmap(MemoryRegionSection *section)
+static int kvm_physical_sync_dirty_bitmap(MemoryRegionSection *section, bool sync)
 {
     KVMState *s = kvm_state;
     unsigned long size, allocated_size = 0;
@@ -446,7 +446,9 @@ static int kvm_physical_sync_dirty_bitmap(MemoryRegionSection *section)
             break;
         }
 
-        kvm_get_dirty_pages_log_range(section, d.dirty_bitmap);
+        if (sync) {
+            kvm_get_dirty_pages_log_range(section, d.dirty_bitmap);
+        }
         start_addr = mem->start_addr + mem->memory_size;
     }
     g_free(d.dirty_bitmap);
@@ -600,7 +602,7 @@ static void kvm_set_phys_mem(MemoryRegionSection *section, bool add)
         old = *mem;
 
         if (mem->flags & KVM_MEM_LOG_DIRTY_PAGES) {
-            kvm_physical_sync_dirty_bitmap(section);
+            kvm_physical_sync_dirty_bitmap(section, true);
         }
 
         /* unregister the overlapping slot */
@@ -733,7 +735,7 @@ static void kvm_log_sync(MemoryListener *listener,
 {
     int r;
 
-    r = kvm_physical_sync_dirty_bitmap(section);
+    r = kvm_physical_sync_dirty_bitmap(section, true);
     if (r < 0) {
         abort();
     }
@@ -744,6 +746,8 @@ static void kvm_log_global_start(struct MemoryListener *listener)
 {
     int r;
 
+    /* Clear the KVM bitmap.  */
+    kvm_physical_sync_dirty_bitmap(section, false);
     r = kvm_set_migration_log(1);
     assert(r >= 0);
 }

  reply	other threads:[~2012-09-25  8:46 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-21  8:46 [Qemu-devel] [PATCH 00/41] Migration cleanups, refactorings, stats, and more Juan Quintela
2012-09-21  8:46 ` [Qemu-devel] [PATCH 01/41] buffered_file: g_realloc() can't fail Juan Quintela
2012-09-21 12:11   ` Paolo Bonzini
2012-09-25  8:08   ` Orit Wasserman
2012-09-21  8:46 ` [Qemu-devel] [PATCH 02/41] fix migration sync Juan Quintela
2012-09-21 12:17   ` Paolo Bonzini
2012-09-25  8:45     ` Paolo Bonzini [this message]
2012-10-02 10:43       ` Juan Quintela
2012-10-02 10:53         ` Paolo Bonzini
2012-09-21  8:46 ` [Qemu-devel] [PATCH 03/41] migration: store end_time in a local variable Juan Quintela
2012-09-21 12:17   ` Paolo Bonzini
2012-09-25  8:10   ` Orit Wasserman
2012-09-21  8:46 ` [Qemu-devel] [PATCH 04/41] migration: print total downtime for final phase of migration Juan Quintela
2012-09-21 12:19   ` Paolo Bonzini
2012-09-25  8:18   ` Orit Wasserman
2012-09-21  8:46 ` [Qemu-devel] [PATCH 05/41] migration: rename expected_time to expected_downtime Juan Quintela
2012-09-21 12:19   ` Paolo Bonzini
2012-09-25  8:21   ` Orit Wasserman
2012-09-21  8:47 ` [Qemu-devel] [PATCH 06/41] migration: export migrate_get_current() Juan Quintela
2012-09-21  8:47 ` [Qemu-devel] [PATCH 07/41] migration: print expected downtime in info migrate Juan Quintela
2012-09-21 12:22   ` Paolo Bonzini
2012-10-02 10:47     ` Juan Quintela
2012-09-21  8:47 ` [Qemu-devel] [PATCH 08/41] savevm: Factorize ram globals reset in its own function Juan Quintela
2012-09-25  8:37   ` Orit Wasserman
2012-09-21  8:47 ` [Qemu-devel] [PATCH 09/41] ram: introduce migration_bitmap_set_dirty() Juan Quintela
2012-09-25  8:38   ` Orit Wasserman
2012-09-21  8:47 ` [Qemu-devel] [PATCH 10/41] ram: Introduce migration_bitmap_test_and_reset_dirty() Juan Quintela
2012-09-25  9:35   ` Orit Wasserman
2012-09-21  8:47 ` [Qemu-devel] [PATCH 11/41] ram: Export last_ram_offset() Juan Quintela
2012-09-21  8:47 ` [Qemu-devel] [PATCH 12/41] ram: introduce migration_bitmap_sync() Juan Quintela
2012-09-21  8:47 ` [Qemu-devel] [PATCH 13/41] ram: create trace event for migration sync bitmap Juan Quintela
2012-09-21  8:47 ` [Qemu-devel] [PATCH 14/41] Separate migration bitmap Juan Quintela
2012-09-21  8:47 ` [Qemu-devel] [PATCH 15/41] migration: Add dirty_pages_rate to query migrate output Juan Quintela
2012-09-21 12:33   ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 16/41] BufferedFile: append, then flush Juan Quintela
2012-09-21  8:47 ` [Qemu-devel] [PATCH 17/41] buffered_file: rename opaque to migration_state Juan Quintela
2012-09-25 11:41   ` Orit Wasserman
2012-10-02 10:54     ` Juan Quintela
2012-09-21  8:47 ` [Qemu-devel] [PATCH 18/41] buffered_file: opaque is MigrationState Juan Quintela
2012-09-25 11:46   ` Orit Wasserman
2012-09-28  7:33     ` Juan Quintela
2012-09-28  7:48       ` Orit Wasserman
2012-09-21  8:47 ` [Qemu-devel] [PATCH 19/41] buffered_file: unfold migrate_fd_put_buffer Juan Quintela
2012-09-21  8:47 ` [Qemu-devel] [PATCH 20/41] buffered_file: unfold migrate_fd_put_ready Juan Quintela
2012-09-21  8:47 ` [Qemu-devel] [PATCH 21/41] buffered_file: unfold migrate_fd_put_buffer Juan Quintela
2012-09-21 12:34   ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 22/41] " Juan Quintela
2012-09-21 12:35   ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 23/41] buffered_file: We can access directly to bandwidth_limit Juan Quintela
2012-09-21 12:35   ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 24/41] buffered_file: callers of buffered_flush() already check for errors Juan Quintela
2012-09-21 12:39   ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 25/41] buffered_file: make buffered_flush return the error code Juan Quintela
2012-09-21 12:43   ` Paolo Bonzini
2012-10-02 11:06     ` Juan Quintela
2012-10-02 11:16       ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 26/41] migration: make migrate_fd_wait_for_unfreeze() return errors Juan Quintela
2012-09-21 12:44   ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 27/41] savevm: unexport qemu_fflush Juan Quintela
2012-09-21 12:45   ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 28/41] virtio-net: use qemu_get_buffer() in a temp buffer Juan Quintela
2012-09-21 12:45   ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 29/41] savevm: Remove qemu_fseek() Juan Quintela
2012-09-21 12:46   ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 30/41] savevm: make qemu_fflush() return an error code Juan Quintela
2012-09-21 12:46   ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 31/41] savevm: unfold qemu_fclose_internal() Juan Quintela
2012-09-21 12:48   ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 32/41] savevm: unexport qemu_ftell() Juan Quintela
2012-09-21 12:48   ` Paolo Bonzini
2012-09-21 15:42     ` Juan Quintela
2012-09-21  8:47 ` [Qemu-devel] [PATCH 33/41] savevm: make qemu_fill_buffer() be consistent Juan Quintela
2012-09-21 12:48   ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 34/41] savevm: Only qemu_fflush() can generate errors Juan Quintela
2012-09-21 12:49   ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 35/41] buffered_file: buffered_put_buffer() don't need to set last_error Juan Quintela
2012-09-21 12:50   ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 36/41] block-migration: make flush_blks() return errors Juan Quintela
2012-09-21 12:50   ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 37/41] block-migration: Switch meaning of return value Juan Quintela
2012-09-21 12:51   ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 38/41] block-migration: handle errors with the return codes correctly Juan Quintela
2012-09-21 12:53   ` Paolo Bonzini
2012-09-24 18:24     ` Juan Quintela
2012-09-25  6:36       ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 39/41] savevm: un-export qemu_file_set_error() Juan Quintela
2012-09-21 12:53   ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 40/41] savevm: make qemu_file_put_notify() return errors Juan Quintela
2012-09-21 12:53   ` Paolo Bonzini
2012-09-21  8:47 ` [Qemu-devel] [PATCH 41/41] cpus: create qemu_cpu_is_vcpu() Juan Quintela
2012-09-21 12:54   ` Paolo Bonzini
2012-09-21 14:48     ` Andreas Färber
2012-09-21 15:36       ` Paolo Bonzini
2012-09-24 18:11     ` Juan Quintela
  -- strict thread matches above, loose matches on Subject: below --
2012-10-02 11:32 [Qemu-devel] [PATCH v2 00/41] Migration cleanups, refactorings, stats, and more Juan Quintela
2012-10-02 11:32 ` [Qemu-devel] [PATCH 02/41] fix migration sync Juan Quintela
2012-10-02 11:37   ` Paolo Bonzini

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=50616F38.1000201@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=avi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.