From: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: [Qemu-devel] Re: [PATCH 09/10] kvm: port qemu-kvm's bitmap scanning
Date: Tue, 27 Apr 2010 13:49:15 +0900 [thread overview]
Message-ID: <w2t87e9effc1004262149ra6bdb069o71c450daa50ae468@mail.gmail.com> (raw)
In-Reply-To: <ee77f42636515888fe6c96a6011528b76aa8ee3d.1272304746.git.mtosatti@redhat.com>
Hi,
This patch may conflict with the patch I posted on April 19.
http://www.mail-archive.com/qemu-devel@nongnu.org/msg29941.html
If Marcelo's is going to be merged, I need to rebase the above to it.
It would be helpful if you could tell me the plan.
Thanks,
Yoshi
2010/4/27 Marcelo Tosatti <mtosatti@redhat.com>:
> Which is significantly faster.
>
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
> ---
> kvm-all.c | 53 +++++++++++++++++++++++++++++++++++++----------------
> 1 files changed, 37 insertions(+), 16 deletions(-)
>
> diff --git a/kvm-all.c b/kvm-all.c
> index eabb097..ef45418 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -26,6 +26,7 @@
> #include "hw/hw.h"
> #include "gdbstub.h"
> #include "kvm.h"
> +#include "bswap.h"
>
> /* KVM uses PAGE_SIZE in it's definition of COALESCED_MMIO_MAX */
> #define PAGE_SIZE TARGET_PAGE_SIZE
> @@ -282,11 +283,41 @@ static int kvm_set_migration_log(int enable)
> return 0;
> }
>
> -static int test_le_bit(unsigned long nr, unsigned char *addr)
> +/* get kvm's dirty pages bitmap and update qemu's */
> +static int kvm_get_dirty_pages_log_range(unsigned long start_addr,
> + unsigned long *bitmap,
> + unsigned long offset,
> + unsigned long mem_size)
> {
> - return (addr[nr >> 3] >> (nr & 7)) & 1;
> + unsigned int i, j;
> + unsigned long page_number, addr, addr1, c;
> + ram_addr_t ram_addr;
> + unsigned int len = ((mem_size / TARGET_PAGE_SIZE) + HOST_LONG_BITS - 1) /
> + HOST_LONG_BITS;
> +
> + /*
> + * 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[i] != 0) {
> + c = leul_to_cpu(bitmap[i]);
> + do {
> + 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);
> + } while (c != 0);
> + }
> + }
> + return 0;
> }
>
> +#define ALIGN(x, y) (((x)+(y)-1) & ~((y)-1))
> +
> /**
> * kvm_physical_sync_dirty_bitmap - Grab dirty bitmap from kernel space
> * This function updates qemu's dirty bitmap using cpu_physical_memory_set_dirty().
> @@ -300,8 +331,6 @@ static int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
> {
> KVMState *s = kvm_state;
> unsigned long size, allocated_size = 0;
> - target_phys_addr_t phys_addr;
> - ram_addr_t addr;
> KVMDirtyLog d;
> KVMSlot *mem;
> int ret = 0;
> @@ -313,7 +342,7 @@ static int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
> break;
> }
>
> - size = ((mem->memory_size >> TARGET_PAGE_BITS) + 7) / 8;
> + size = ALIGN(((mem->memory_size) >> TARGET_PAGE_BITS), HOST_LONG_BITS) / 8;
> if (!d.dirty_bitmap) {
> d.dirty_bitmap = qemu_malloc(size);
> } else if (size > allocated_size) {
> @@ -330,17 +359,9 @@ static int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
> break;
> }
>
> - for (phys_addr = mem->start_addr, addr = mem->phys_offset;
> - phys_addr < mem->start_addr + mem->memory_size;
> - phys_addr += TARGET_PAGE_SIZE, addr += TARGET_PAGE_SIZE) {
> - unsigned char *bitmap = (unsigned char *)d.dirty_bitmap;
> - unsigned nr = (phys_addr - mem->start_addr) >> TARGET_PAGE_BITS;
> -
> - if (test_le_bit(nr, bitmap)) {
> - cpu_physical_memory_set_dirty(addr);
> - }
> - }
> - start_addr = phys_addr;
> + kvm_get_dirty_pages_log_range(mem->start_addr, d.dirty_bitmap,
> + mem->start_addr, mem->memory_size);
> + start_addr = mem->start_addr + mem->memory_size;
> }
> qemu_free(d.dirty_bitmap);
>
> --
> 1.6.6.1
next prev parent reply other threads:[~2010-04-27 4:49 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-26 17:58 [Qemu-devel] [PATCH 00/10] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
2010-04-26 17:58 ` [Qemu-devel] [PATCH 01/10] KVM: x86: Add debug register saving and restoring Marcelo Tosatti
2010-04-26 17:58 ` [Qemu-devel] [PATCH 02/10] target-i386: print EFER in cpu_dump_state Marcelo Tosatti
2010-04-26 17:58 ` [Qemu-devel] [PATCH 03/10] kvm: handle internal error Marcelo Tosatti
2010-04-26 17:59 ` [Qemu-devel] [PATCH 04/10] kvm: allow qemu to set EPT identity mapping address Marcelo Tosatti
2010-04-26 17:59 ` [Qemu-devel] [PATCH 05/10] kvm_init_vcpu requires global lock held Marcelo Tosatti
2010-04-26 17:59 ` [Qemu-devel] [PATCH 06/10] kvm: remove explicit kvm_arch_reset_vcpu from kvm_init_vcpu Marcelo Tosatti
2010-04-28 15:39 ` [Qemu-devel] " Anthony Liguori
2010-04-28 16:22 ` Marcelo Tosatti
2010-04-28 16:42 ` Marcelo Tosatti
2010-04-28 16:46 ` Anthony Liguori
2010-04-26 17:59 ` [Qemu-devel] [PATCH 07/10] vga: fix typo in length passed to kvm_log_stop Marcelo Tosatti
2010-04-26 17:59 ` [Qemu-devel] [PATCH 08/10] introduce leul_to_cpu Marcelo Tosatti
2010-04-26 17:59 ` [Qemu-devel] [PATCH 09/10] kvm: port qemu-kvm's bitmap scanning Marcelo Tosatti
2010-04-27 4:49 ` Yoshiaki Tamura [this message]
2010-04-27 14:42 ` [Qemu-devel] " Marcelo Tosatti
2010-04-27 23:09 ` Yoshiaki Tamura
2010-04-26 17:59 ` [Qemu-devel] [PATCH 10/10] introduce qemu_ram_map Marcelo Tosatti
2010-04-26 18:27 ` [Qemu-devel] " Anthony Liguori
2010-04-26 18:49 ` Marcelo Tosatti
2010-04-26 18:54 ` Anthony Liguori
2010-04-27 14:28 ` Cam Macdonell
2010-04-27 14:49 ` Marcelo Tosatti
2010-04-26 18:29 ` Anthony Liguori
2010-04-26 18:50 ` Marcelo Tosatti
2010-04-26 18:57 ` Anthony Liguori
2010-04-26 19:14 ` Marcelo Tosatti
2010-04-26 19:20 ` Anthony Liguori
2010-04-26 19:45 ` Marcelo Tosatti
2010-04-27 14:32 ` Cam Macdonell
2010-04-27 14:50 ` Marcelo Tosatti
2010-05-03 13:02 ` [Qemu-devel] Re: [PATCH 00/10] [PULL] qemu-kvm.git uq/master queue Anthony Liguori
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=w2t87e9effc1004262149ra6bdb069o71c450daa50ae468@mail.gmail.com \
--to=tamura.yoshiaki@lab.ntt.co.jp \
--cc=aliguori@us.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--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).