From mboxrd@z Thu Jan 1 00:00:00 1970 From: OHMURA Kei Subject: Re: [PATCH] qemu-kvm: Speed up of the dirty-bitmap-traveling Date: Wed, 10 Feb 2010 18:55:49 +0900 Message-ID: <4B7282A5.7090500@lab.ntt.co.jp> References: <4B6BF06D.1090909@lab.ntt.co.jp> <4B70065B.1010401@redhat.com> <4B7130E9.7060809@lab.ntt.co.jp> <4B713839.30301@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org, mtosatti@redhat.com, ohmura.kei@lab.ntt.co.jp To: Avi Kivity Return-path: Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]:40406 "EHLO tama500.ecl.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753475Ab0BJJ4L (ORCPT ); Wed, 10 Feb 2010 04:56:11 -0500 In-Reply-To: <4B713839.30301@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: > Please reuse the changelog when reposing a patch, this makes it easier > for me to apply it. Thanks. Will follow it from next time. > Should be a host long size, not guest. This will fail when running a > 32-bit qemu-system-x86_64 binary. Sorry. That was our mistake. > 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); } } }