From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nf9kR-0000GV-Lx for qemu-devel@nongnu.org; Wed, 10 Feb 2010 05:24:43 -0500 Received: from [199.232.76.173] (port=59674 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nf9kQ-0000Fx-5K for qemu-devel@nongnu.org; Wed, 10 Feb 2010 05:24:42 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nf9kP-0001Rh-HD for qemu-devel@nongnu.org; Wed, 10 Feb 2010 05:24:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:61027) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nf9kP-0001Rd-3e for qemu-devel@nongnu.org; Wed, 10 Feb 2010 05:24:41 -0500 Message-ID: <4B72895E.7050006@redhat.com> Date: Wed, 10 Feb 2010 12:24:30 +0200 From: Avi Kivity MIME-Version: 1.0 References: <4B6BF06D.1090909@lab.ntt.co.jp> <4B70065B.1010401@redhat.com> <4B7130E9.7060809@lab.ntt.co.jp> <4B713839.30301@redhat.com> <4B7282A5.7090500@lab.ntt.co.jp> In-Reply-To: <4B7282A5.7090500@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: mtosatti@redhat.com, qemu-devel@nongnu.org, kvm@vger.kernel.org On 02/10/2010 11:55 AM, OHMURA Kei wrote: > >> Instead of using a nested loop if bitmap_ul[i] != 0, it is possible to >> use just a single loop (while (c> 0)), and process a long's worth of data. >> >> The only trickery is with big endian hosts, where the conversion from >> bit number to page number is a bit complicated. >> > To convert the bitmap from big endian to little endian, le_bswap macro in > bswap.h seems useful, which is now undefined. What do you think about this > approach? > > This is an example bitmap-traveling code using le_bswap: > /* > * bitmap-traveling is faster than memory-traveling (for addr...) > * especially when most of the memory is not dirty. > */ > for (i = 0; i < len; i++) { > if (bitmap_ul[i] != 0) { > c = le_bswap(bitmap_ul[i], HOST_LONG_BITS); > while (c > 0) { > 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); > } > } > } > Yes, that solves the problem very neatly. -- error compiling committee.c: too many arguments to function