qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 02/41] fix migration sync


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 02/41] fix migration sync
Date: Tue, 25 Sep 2012 10:45:44 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120911 Thunderbird/15.0.1

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 via email to

[Prev in Thread] Current Thread [Next in Thread]