From: Avi Kivity <avi@redhat.com>
To: OHMURA Kei <ohmura.kei@lab.ntt.co.jp>
Cc: mtosatti@redhat.com, qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: [Qemu-devel] Re: [PATCH] qemu-kvm: Speed up of the dirty-bitmap-traveling
Date: Tue, 09 Feb 2010 12:26:01 +0200 [thread overview]
Message-ID: <4B713839.30301@redhat.com> (raw)
In-Reply-To: <4B7130E9.7060809@lab.ntt.co.jp>
On 02/09/2010 11:54 AM, OHMURA Kei wrote:
> Thank you for your comments. We have implemented the code which applied your
> comments. This is patch for qemu-kvm.c.
>
Please reuse the changelog when reposing a patch, this makes it easier
for me to apply it.
> @@ -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;
>
Should be a host long size, not guest. This will fail when running a
32-bit qemu-system-x86_64 binary.
> + 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);
> + }
> + }
>
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.
If we do this, we can convert the bitmap's type to unsigned long
throughout, and avoid the casts.
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2010-02-09 10:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-05 10:18 [Qemu-devel] [PATCH] qemu-kvm: Speed up of the dirty-bitmap-traveling OHMURA Kei
2010-02-05 12:04 ` [Qemu-devel] " Jan Kiszka
2010-02-08 6:14 ` OHMURA Kei
2010-02-08 11:23 ` OHMURA Kei
2010-02-08 11:44 ` Jan Kiszka
2010-02-09 9:55 ` OHMURA Kei
2010-02-08 12:40 ` Avi Kivity
2010-02-09 9:54 ` OHMURA Kei
2010-02-09 10:26 ` Avi Kivity [this message]
2010-02-10 9:55 ` OHMURA Kei
2010-02-10 10:24 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B713839.30301@redhat.com \
--to=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=ohmura.kei@lab.ntt.co.jp \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).