From patchwork Mon Apr 27 16:28:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 465123 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 21790140079 for ; Tue, 28 Apr 2015 02:37:29 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=dlACrzXW; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: from localhost ([::1]:56341 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ymm2B-00077k-3W for incoming@patchwork.ozlabs.org; Mon, 27 Apr 2015 12:37:27 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=brjoo+7db5gauRBy0PSJYU2MsAj/wq/gIyRsa7oZM94=; b=dlACrzXW4GeRjeXq4LPtm/QGr+ig2/+vnldAN+Wp2FVDJiH9tjaCAa2cvUv+g/acNV 0ghgJK8HY5ztIkhCVB90XKHOg3CJGtClOu4/EbLm4PsSqwsx3QkyeCr7Jt8VZ9oeE4ge sN7kT+MeIaFnADqtsTPv+rCkkQHywkQanjWtS3ObOCcrxgSStYrxD/M2FyunGn8+JzXe Zq2dmuW9XIcYLZbyI5rMKFJke1Flim3DOexXSbH5w4igG0BM2uQeiTnBHTExFfUW45ik LXQVwY0YTACet3SiFn+050t+lEKeFfvdQO/7/s8+Wmdixgr2bKiKKf+sGYPoC6wqPlnA vV0A== X-Received: by 10.194.185.229 with SMTP id ff5mr23821591wjc.30.1430152227611; Mon, 27 Apr 2015 09:30:27 -0700 (PDT) Received: from 640k.localdomain (net-37-116-199-255.cust.vodafonedsl.it. [37.116.199.255]) by mx.google.com with ESMTPSA id dz4sm12300651wib.17.2015.04.27.09.30.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Apr 2015 09:30:26 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 27 Apr 2015 18:28:19 +0200 Message-Id: <1430152117-100558-12-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1430152117-100558-1-git-send-email-pbonzini@redhat.com> References: <1430152117-100558-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22f Cc: famz@redhat.com, stefanha@redhat.com, mst@redhat.com Subject: [Qemu-devel] [PATCH 11/29] memory: include DIRTY_MEMORY_MIGRATION in the dirty log mask X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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); }