From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NeSvT-0007Bd-RN for qemu-devel@nongnu.org; Mon, 08 Feb 2010 07:41:15 -0500 Received: from [199.232.76.173] (port=43370 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NeSvT-0007BJ-68 for qemu-devel@nongnu.org; Mon, 08 Feb 2010 07:41:15 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NeSvS-00030y-9Q for qemu-devel@nongnu.org; Mon, 08 Feb 2010 07:41:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45341) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NeSvR-00030m-Qs for qemu-devel@nongnu.org; Mon, 08 Feb 2010 07:41:14 -0500 Message-ID: <4B70065B.1010401@redhat.com> Date: Mon, 08 Feb 2010 14:40:59 +0200 From: Avi Kivity MIME-Version: 1.0 References: <4B6BF06D.1090909@lab.ntt.co.jp> In-Reply-To: <4B6BF06D.1090909@lab.ntt.co.jp> Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH] qemu-kvm: Speed up of the dirty-bitmap-traveling List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: OHMURA Kei Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org On 02/05/2010 12:18 PM, OHMURA Kei wrote: > dirty-bitmap-traveling is carried out by byte size in qemu-kvm.c. > But We think that dirty-bitmap-traveling by long size is faster than by byte > size especially when most of memory is not dirty. > > > > + > +static int kvm_get_dirty_pages_log_range_by_long(unsigned long start_addr, > + unsigned char *bitmap, > + unsigned long offset, > + unsigned long mem_size) > +{ > + unsigned int i; > + unsigned int len; > + unsigned long *bitmap_ul = (unsigned long *)bitmap; > + > + /* bitmap-traveling by long size is faster than by byte size > + * especially when most of memory is not dirty. > + * bitmap should be long-size aligned for traveling by long. > + */ > + if (((unsigned long)bitmap & (TARGET_LONG_SIZE - 1)) == 0) { > Since we allocate the bitmap, we can be sure that it is aligned on a long boundary (qemu_malloc() should guarantee that). So you can eliminate the fallback. > + len = ((mem_size / TARGET_PAGE_SIZE) + TARGET_LONG_BITS - 1) / > + TARGET_LONG_BITS; > + for (i = 0; i < len; i++) > + if (bitmap_ul[i] != 0) > + kvm_get_dirty_pages_log_range_by_byte(i * TARGET_LONG_SIZE, > + (i + 1) * TARGET_LONG_SIZE, bitmap, offset); > Better to just use the original loop here (since we don't need the function as a fallback). > + /* > + * We will check the remaining dirty-bitmap, > + * when the mem_size is not a multiple of TARGET_LONG_SIZE. > + */ > + if ((mem_size & (TARGET_LONG_SIZE - 1)) != 0) { > + len = ((mem_size / TARGET_PAGE_SIZE) + 7) / 8; > + kvm_get_dirty_pages_log_range_by_byte(i * TARGET_LONG_SIZE, > + len, bitmap, offset); > + } > Seems like the bitmap size is also aligned as well (allocated using BITMAP_SIZE which aligns using HOST_LONG_BITS), so this is unnecessary as well. -- error compiling committee.c: too many arguments to function