From patchwork Tue Feb 9 09:54:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: OHMURA Kei X-Patchwork-Id: 77989 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o199tFkN006495 for ; Tue, 9 Feb 2010 09:55:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751674Ab0BIJzN (ORCPT ); Tue, 9 Feb 2010 04:55:13 -0500 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]:56874 "EHLO tama500.ecl.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751423Ab0BIJzM (ORCPT ); Tue, 9 Feb 2010 04:55:12 -0500 Received: from mfs5.rdh.ecl.ntt.co.jp (mfs5.rdh.ecl.ntt.co.jp [129.60.39.144]) by tama500.ecl.ntt.co.jp (8.14.3/8.14.3) with ESMTP id o199smiC006240; Tue, 9 Feb 2010 18:54:48 +0900 (JST) Received: from mfs5.rdh.ecl.ntt.co.jp (localhost [127.0.0.1]) by mfs5.rdh.ecl.ntt.co.jp (Postfix) with ESMTP id C694D6CDF; Tue, 9 Feb 2010 18:54:48 +0900 (JST) Received: from dmailsv1.y.ecl.ntt.co.jp (dmailsv1.y.ecl.ntt.co.jp [129.60.53.14]) by mfs5.rdh.ecl.ntt.co.jp (Postfix) with ESMTP id A4E6F6CDD; Tue, 9 Feb 2010 18:54:48 +0900 (JST) Received: from mailsv02.y.ecl.ntt.co.jp by dmailsv1.y.ecl.ntt.co.jp (8.14.3/dmailsv1-2.1) with ESMTP id o199smDV023412; Tue, 9 Feb 2010 18:54:48 +0900 (JST) Received: from localhost by mailsv02.y.ecl.ntt.co.jp (8.14.3/Lab-1.7) with ESMTP id o199smB0011272; Tue, 9 Feb 2010 18:54:48 +0900 (JST) Message-ID: <4B7130E9.7060809@lab.ntt.co.jp> Date: Tue, 09 Feb 2010 18:54:49 +0900 From: OHMURA Kei User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Avi Kivity CC: kvm@vger.kernel.org, qemu-devel@nongnu.org, mtosatti@redhat.com, ohmura.kei@lab.ntt.co.jp Subject: Re: [PATCH] qemu-kvm: Speed up of the dirty-bitmap-traveling References: <4B6BF06D.1090909@lab.ntt.co.jp> <4B70065B.1010401@redhat.com> In-Reply-To: <4B70065B.1010401@redhat.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 09 Feb 2010 09:55:15 +0000 (UTC) diff --git a/qemu-kvm.c b/qemu-kvm.c index a305907..d7474ea 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -2438,27 +2438,34 @@ static int kvm_get_dirty_pages_log_range(unsigned long start_addr, unsigned long offset, unsigned long mem_size) { - unsigned int i, j, n = 0; + unsigned int i, j, k, start, end; unsigned char c; unsigned long page_number, addr, addr1; ram_addr_t ram_addr; - unsigned int len = ((mem_size / TARGET_PAGE_SIZE) + 7) / 8; + unsigned int len = ((mem_size / TARGET_PAGE_SIZE) + TARGET_LONG_BITS - 1) / + TARGET_LONG_BITS; + unsigned long *bitmap_ul = (unsigned long *)bitmap; /* * bitmap-traveling is faster than memory-traveling (for addr...) * especially when most of the memory is not dirty. */ for (i = 0; i < len; i++) { - c = bitmap[i]; - while (c > 0) { - j = ffsl(c) - 1; - c &= ~(1u << j); - page_number = i * 8 + 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); - n++; + if (bitmap_ul[i] != 0) { + start = i * TARGET_LONG_SIZE; + end = (i + 1) * TARGET_LONG_SIZE; + for (j = start; j < end; j++) { + c = bitmap[j]; + while (c > 0) { + k = ffsl(c) - 1; + c &= ~(1u << k); + page_number = j * 8 + k; + addr1 = page_number * TARGET_PAGE_SIZE; + addr = offset + addr1; + ram_addr = cpu_get_physical_page_desc(addr); + cpu_physical_memory_set_dirty(ram_addr); + } + } } } return 0;