From patchwork Mon Jun 7 04:28:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshiaki Tamura X-Patchwork-Id: 54827 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C1CF11007D1 for ; Mon, 7 Jun 2010 14:33:55 +1000 (EST) Received: from localhost ([127.0.0.1]:47495 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OLU24-0005Fl-TF for incoming@patchwork.ozlabs.org; Mon, 07 Jun 2010 00:33:52 -0400 Received: from [140.186.70.92] (port=34376 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OLTy3-0002ym-7v for qemu-devel@nongnu.org; Mon, 07 Jun 2010 00:29:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OLTxz-0000k8-Q1 for qemu-devel@nongnu.org; Mon, 07 Jun 2010 00:29:43 -0400 Received: from sh.osrg.net ([192.16.179.4]:41604) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OLTxz-0000j4-9M for qemu-devel@nongnu.org; Mon, 07 Jun 2010 00:29:39 -0400 Received: from fs.osrg.net (postfix@fs.osrg.net [10.0.0.12]) by sh.osrg.net (8.14.3/8.14.3/OSRG-NET) with ESMTP id o574TV0x022714; Mon, 7 Jun 2010 13:29:31 +0900 Received: from localhost (hype-wd0.osrg.net [10.72.1.16]) by fs.osrg.net (Postfix) with ESMTP id BDD7E3E02E7; Mon, 7 Jun 2010 13:29:31 +0900 (JST) From: Yoshiaki Tamura To: qemu-devel@nongnu.org Date: Mon, 7 Jun 2010 13:28:03 +0900 Message-Id: <1275884884-12133-4-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> X-Mailer: git-send-email 1.7.0.31.g1df487 In-Reply-To: <1275884884-12133-1-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> References: <1275884884-12133-1-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> X-Dispatcher: imput version 20070423(IM149) Lines: 67 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (sh.osrg.net [192.16.179.4]); Mon, 07 Jun 2010 13:29:32 +0900 (JST) X-Virus-Scanned: clamav-milter 0.96 at sh X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: aliguori@us.ibm.com, avi@redhat.com, Yoshiaki Tamura , ohmura.kei@lab.ntt.co.jp Subject: [Qemu-devel] [PATCH v5 RESEND 3/4] Use cpu_physical_memory_set_dirty_range() to update phys_ram_dirty. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Modifies kvm_physical_sync_dirty_bitmap to use cpu_physical_memory_set_dirty_range() to update the row of the bit-based phys_ram_dirty bitmap at once. Signed-off-by: OHMURA Kei Signed-off-by: Yoshiaki Tamura --- kvm-all.c | 24 +++++++++--------------- 1 files changed, 9 insertions(+), 15 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index c238f54..0d29798 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -290,8 +290,8 @@ static int kvm_get_dirty_pages_log_range(unsigned long start_addr, unsigned long offset, unsigned long mem_size) { - unsigned int i, j; - unsigned long page_number, addr, addr1, c; + unsigned int i; + unsigned long page_number, addr, addr1; ram_addr_t ram_addr; unsigned int len = ((mem_size / TARGET_PAGE_SIZE) + HOST_LONG_BITS - 1) / HOST_LONG_BITS; @@ -302,23 +302,17 @@ static int kvm_get_dirty_pages_log_range(unsigned long start_addr, */ for (i = 0; i < len; i++) { if (bitmap[i] != 0) { - c = leul_to_cpu(bitmap[i]); - do { - j = ffsl(c) - 1; - c &= ~(1ul << j); - page_number = i * HOST_LONG_BITS + j; - addr1 = page_number * TARGET_PAGE_SIZE; - addr = offset + addr1; - ram_addr = cpu_get_physical_page_desc(addr); - cpu_physical_memory_set_dirty(ram_addr); - } while (c != 0); + page_number = i * HOST_LONG_BITS; + addr1 = page_number * TARGET_PAGE_SIZE; + addr = offset + addr1; + ram_addr = cpu_get_physical_page_desc(addr); + cpu_physical_memory_set_dirty_range(ram_addr, + leul_to_cpu(bitmap[i])); } } return 0; } -#define ALIGN(x, y) (((x)+(y)-1) & ~((y)-1)) - /** * kvm_physical_sync_dirty_bitmap - Grab dirty bitmap from kernel space * This function updates qemu's dirty bitmap using cpu_physical_memory_set_dirty(). @@ -343,7 +337,7 @@ static int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, break; } - size = ALIGN(((mem->memory_size) >> TARGET_PAGE_BITS), HOST_LONG_BITS) / 8; + size = BITMAP_SIZE(mem->memory_size); if (!d.dirty_bitmap) { d.dirty_bitmap = qemu_malloc(size); } else if (size > allocated_size) {