qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Umesh Deshpande <udeshpan@redhat.com>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, kvm@vger.kernel.org,
	Juan Quintela <quintela@redhat.com>
Subject: Re: [Qemu-devel] [RFC PATCH v2 3/3] Per memslot dirty bitmap
Date: Tue, 2 Aug 2011 13:29:22 -0300	[thread overview]
Message-ID: <20110802162922.GA5144@amt.cnet> (raw)
In-Reply-To: <05d7d0f43e05e61176930427b33574b212e3c7e7.1311971938.git.udeshpan@redhat.com>

On Fri, Jul 29, 2011 at 04:57:26PM -0400, Umesh Deshpande wrote:
> This patch creates a separate dirty bitmap for each slot. Currently dirty bitmap
> is created for addresses ranging from 0 to the end address of the last memory
> slot. Since the memslots are not necessarily contiguous, current bitmap might
> contain empty region or holes that doesn't represent any VM pages. This patch
> reduces the size of the dirty bitmap by allocating per memslot dirty bitmaps.
> 
> Signed-off-by: Umesh Deshpande <udeshpan@redhat.com>
> ---
>  cpu-all.h |   40 +++++++++++++++++++++++++++++++++-------
>  exec.c    |   38 +++++++++++++++++++++++---------------
>  xen-all.c |    6 ++----
>  3 files changed, 58 insertions(+), 26 deletions(-)
> 
> diff --git a/cpu-all.h b/cpu-all.h
> index e839100..9517a9b 100644
> --- a/cpu-all.h
> +++ b/cpu-all.h
> @@ -920,6 +920,7 @@ extern ram_addr_t ram_size;
>  
>  typedef struct RAMBlock {
>      uint8_t *host;
> +    uint8_t *phys_dirty;
>      ram_addr_t offset;
>      ram_addr_t length;
>      uint32_t flags;
> @@ -931,7 +932,6 @@ typedef struct RAMBlock {
>  } RAMBlock;
>  
>  typedef struct RAMList {
> -    uint8_t *phys_dirty;
>      QLIST_HEAD(ram, RAMBlock) blocks;
>  } RAMList;
>  extern RAMList ram_list;
> @@ -961,32 +961,55 @@ extern int mem_prealloc;
>  #define CODE_DIRTY_FLAG      0x02
>  #define MIGRATION_DIRTY_FLAG 0x08
>  
> +RAMBlock *qemu_addr_to_ramblock(ram_addr_t);
> +
> +static inline int get_page_nr(ram_addr_t addr, RAMBlock **block)
> +{
> +    int page_nr;
> +    *block = qemu_addr_to_ramblock(addr);
> +
> +    page_nr = addr - (*block)->offset;
> +    page_nr = page_nr >> TARGET_PAGE_BITS;
> +
> +    return page_nr;
> +}
> +
>  /* read dirty bit (return 0 or 1) */
>  static inline int cpu_physical_memory_is_dirty(ram_addr_t addr)
>  {
> -    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] == 0xff;
> +    RAMBlock *block;
> +    int page_nr = get_page_nr(addr, &block);
> +    return block->phys_dirty[page_nr] == 0xff;
>  }
>  
>  static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr)
>  {
> -    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS];
> +    RAMBlock *block;
> +    int page_nr = get_page_nr(addr, &block);
> +    return block->phys_dirty[page_nr];
>  }
>  
>  static inline int cpu_physical_memory_get_dirty(ram_addr_t addr,
>                                                  int dirty_flags)
>  {
> -    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] & dirty_flags;
> +    RAMBlock *block;
> +    int page_nr = get_page_nr(addr, &block);
> +    return block->phys_dirty[page_nr] & dirty_flags;
>  }
>  
>  static inline void cpu_physical_memory_set_dirty(ram_addr_t addr)
>  {
> -    ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] = 0xff;
> +    RAMBlock *block;
> +    int page_nr = get_page_nr(addr, &block);
> +    block->phys_dirty[page_nr] = 0xff;
>  }
>  
>  static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr,
>                                                        int dirty_flags)
>  {
> -    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags;
> +    RAMBlock *block;
> +    int page_nr = get_page_nr(addr, &block);
> +    return block->phys_dirty[page_nr] |= dirty_flags;
>  }
>  
>  static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start,
> @@ -995,10 +1018,13 @@ static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start,
>  {
>      int i, mask, len;
>      uint8_t *p;
> +    RAMBlock *block;
> +    int page_nr = get_page_nr(start, &block);
>  
>      len = length >> TARGET_PAGE_BITS;
>      mask = ~dirty_flags;
> -    p = ram_list.phys_dirty + (start >> TARGET_PAGE_BITS);
> +
> +    p = block->phys_dirty + page_nr;
>          p[i] &= mask;
>      }
> diff --git a/exec.c b/exec.c
> index 0e2ce57..6312550 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -2106,6 +2106,10 @@ void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
>          abort();
>      }
>  
> +    if (kvm_enabled()) {
> +        return;
> +    }
> +

This belongs to a separate patch.

  reply	other threads:[~2011-08-02 19:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-29 20:57 [Qemu-devel] [RFC PATCH v2 0/3] separate thread for VM migration Umesh Deshpande
2011-07-29 20:57 ` [Qemu-devel] [RFC PATCH v2 1/3] " Umesh Deshpande
2011-08-01  9:37   ` Paolo Bonzini
2011-08-01 21:00     ` Umesh Deshpande
2011-08-02  7:44       ` Paolo Bonzini
2011-07-29 20:57 ` [Qemu-devel] [RFC PATCH v2 2/3] fine grained qemu_mutex locking for migration Umesh Deshpande
2011-08-01  9:39   ` Paolo Bonzini
2011-08-02 16:30   ` Marcelo Tosatti
2011-07-29 20:57 ` [Qemu-devel] [RFC PATCH v2 3/3] Per memslot dirty bitmap Umesh Deshpande
2011-08-02 16:29   ` Marcelo Tosatti [this message]
2011-08-01  9:41 ` [Qemu-devel] [RFC PATCH v2 0/3] separate thread for VM migration shawn che

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=20110802162922.GA5144@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=udeshpan@redhat.com \
    /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).