From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmlvW-00022j-MU for qemu-devel@nongnu.org; Mon, 27 Apr 2015 12:30:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YmlvQ-00031B-C5 for qemu-devel@nongnu.org; Mon, 27 Apr 2015 12:30:33 -0400 Received: from mail-wi0-x22f.google.com ([2a00:1450:400c:c05::22f]:35123) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmlvQ-00030k-3y for qemu-devel@nongnu.org; Mon, 27 Apr 2015 12:30:28 -0400 Received: by widdi4 with SMTP id di4so106398197wid.0 for ; Mon, 27 Apr 2015 09:30:27 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 27 Apr 2015 18:28:19 +0200 Message-Id: <1430152117-100558-12-git-send-email-pbonzini@redhat.com> In-Reply-To: <1430152117-100558-1-git-send-email-pbonzini@redhat.com> References: <1430152117-100558-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 11/29] memory: include DIRTY_MEMORY_MIGRATION in the dirty log mask List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: famz@redhat.com, stefanha@redhat.com, mst@redhat.com The separate handling of DIRTY_MEMORY_MIGRATION, which does not call log_start/log_stop callbacks when it changes in a region's dirty logging mask, has caused several bugs. One recent example is commit 4cc856f (kvm-all: Sync dirty-bitmap from kvm before kvm destroy the corresponding dirty_bitmap, 2015-04-02). Another performance problem is that KVM keeps tracking dirty pages after a failed live migration, which causes bad performance due to disallowing huge page mapping. This patch removes the root cause of the problem by reporting DIRTY_MEMORY_MIGRATION changes via log_start and log_stop. Note that we now have to rebuild the FlatView when global dirty logging is enabled or disabled; this ensures that log_start and log_stop callbacks are invoked. This will also be used to make the setting of bitmaps conditional. Signed-off-by: Paolo Bonzini --- memory.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/memory.c b/memory.c index 1966347..174cd15 100644 --- a/memory.c +++ b/memory.c @@ -537,7 +537,7 @@ static void render_memory_region(FlatView *view, remain = clip.size; fr.mr = mr; - fr.dirty_log_mask = mr->dirty_log_mask; + fr.dirty_log_mask = memory_region_get_dirty_log_mask(mr); fr.romd_mode = mr->romd_mode; fr.readonly = readonly; @@ -1329,7 +1329,11 @@ bool memory_region_is_skip_dump(MemoryRegion *mr) uint8_t memory_region_get_dirty_log_mask(MemoryRegion *mr) { - return mr->dirty_log_mask; + uint8_t mask = mr->dirty_log_mask; + if (global_dirty_log) { + mask |= (1 << DIRTY_MEMORY_MIGRATION); + } + return mask; } bool memory_region_is_logging(MemoryRegion *mr, uint8_t client) @@ -1892,10 +1896,20 @@ void memory_global_dirty_log_start(void) { global_dirty_log = true; MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward); + + /* Refresh DIRTY_LOG_MIGRATION bit. */ + memory_region_transaction_begin(); + memory_region_update_pending = true; + memory_region_transaction_commit(); } void memory_global_dirty_log_stop(void) { + /* Refresh DIRTY_LOG_MIGRATION bit. */ + memory_region_transaction_begin(); + memory_region_update_pending = true; + memory_region_transaction_commit(); + global_dirty_log = false; MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse); } -- 1.8.3.1