From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:39718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGQmC-0005Bn-S5 for qemu-devel@nongnu.org; Tue, 25 Sep 2012 04:46:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TGQm8-0000CV-85 for qemu-devel@nongnu.org; Tue, 25 Sep 2012 04:45:56 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:55605) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGQm7-0000Am-Vu for qemu-devel@nongnu.org; Tue, 25 Sep 2012 04:45:52 -0400 Received: by pbbrp2 with SMTP id rp2so2823534pbb.4 for ; Tue, 25 Sep 2012 01:45:51 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <50616F38.1000201@redhat.com> Date: Tue, 25 Sep 2012 10:45:44 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1348217255-22441-1-git-send-email-quintela@redhat.com> <1348217255-22441-3-git-send-email-quintela@redhat.com> <505C5AD0.1080903@redhat.com> In-Reply-To: <505C5AD0.1080903@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 02/41] fix migration sync List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: qemu-devel@nongnu.org, Avi Kivity 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); }