From patchwork Thu Oct 18 07:30:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 192225 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4042A2C0098 for ; Thu, 18 Oct 2012 19:05:08 +1100 (EST) Received: from localhost ([::1]:57525 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOl6I-0008BN-8T for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2012 04:05:06 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOkZa-0005yU-8N for qemu-devel@nongnu.org; Thu, 18 Oct 2012 03:31:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOkZW-0000iZ-2k for qemu-devel@nongnu.org; Thu, 18 Oct 2012 03:31:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15083) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOkZV-0000iT-RJ for qemu-devel@nongnu.org; Thu, 18 Oct 2012 03:31:14 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9I7VDhp030231 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 18 Oct 2012 03:31:13 -0400 Received: from trasno.mitica (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q9I7URnk020816; Thu, 18 Oct 2012 03:31:12 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2012 09:30:23 +0200 Message-Id: <1350545426-23172-28-git-send-email-quintela@redhat.com> In-Reply-To: <1350545426-23172-1-git-send-email-quintela@redhat.com> References: <1350545426-23172-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 27/30] ram: Use memory_region_test_and_clear_dirty 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 This avoids having to do two walks over the dirty bitmap, once reading the dirty bits, and anthoer cleaning them. Signed-off-by: Juan Quintela --- arch_init.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch_init.c b/arch_init.c index 6f39ebd..8391375 100644 --- a/arch_init.c +++ b/arch_init.c @@ -390,13 +390,12 @@ static void migration_bitmap_sync(void) 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)) { + if (memory_region_test_and_clear_dirty(block->mr, + addr, TARGET_PAGE_SIZE, + DIRTY_MEMORY_MIGRATION)) { migration_bitmap_set_dirty(block->mr, addr); } } - memory_region_reset_dirty(block->mr, 0, block->length, - DIRTY_MEMORY_MIGRATION); } trace_migration_bitmap_sync_end(migration_dirty_pages - num_dirty_pages_init);