All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>,
	qemu-devel@nongnu.org
Cc: amit.shah@redhat.com, quintela@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/5] migration/ram.c: Use RAMBlock rather than MemoryRegion
Date: Thu, 13 Aug 2015 14:46:35 +0200	[thread overview]
Message-ID: <55CC91AB.4010904@redhat.com> (raw)
In-Reply-To: <1439463094-5394-2-git-send-email-dgilbert@redhat.com>



On 13/08/2015 12:51, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> 
> RAM migration mainly works on RAMBlocks but in a few places
> uses data from MemoryRegions to access the same information that's
> already held in RAMBlocks; clean it up just to avoid the
> MemoryRegion use.
> 
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
>  migration/ram.c | 26 +++++++++++---------------
>  1 file changed, 11 insertions(+), 15 deletions(-)
> 
> diff --git a/migration/ram.c b/migration/ram.c
> index 7f007e6..7df9157 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -497,13 +497,13 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t **current_data,
>  
>  /* Called with rcu_read_lock() to protect migration_bitmap */
>  static inline
> -ram_addr_t migration_bitmap_find_and_reset_dirty(MemoryRegion *mr,
> +ram_addr_t migration_bitmap_find_and_reset_dirty(RAMBlock *rb,
>                                                   ram_addr_t start)
>  {
> -    unsigned long base = mr->ram_addr >> TARGET_PAGE_BITS;
> +    unsigned long base = rb->offset >> TARGET_PAGE_BITS;
>      unsigned long nr = base + (start >> TARGET_PAGE_BITS);
> -    uint64_t mr_size = TARGET_PAGE_ALIGN(memory_region_size(mr));
> -    unsigned long size = base + (mr_size >> TARGET_PAGE_BITS);
> +    uint64_t rb_size = rb->used_length;
> +    unsigned long size = base + (rb_size >> TARGET_PAGE_BITS);
>      unsigned long *bitmap;
>  
>      unsigned long next;
> @@ -573,7 +573,7 @@ static void migration_bitmap_sync(void)
>      qemu_mutex_lock(&migration_bitmap_mutex);
>      rcu_read_lock();
>      QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
> -        migration_bitmap_sync_range(block->mr->ram_addr, block->used_length);
> +        migration_bitmap_sync_range(block->offset, block->used_length);
>      }
>      rcu_read_unlock();
>      qemu_mutex_unlock(&migration_bitmap_mutex);
> @@ -668,12 +668,11 @@ static int ram_save_page(QEMUFile *f, RAMBlock* block, ram_addr_t offset,
>      int pages = -1;
>      uint64_t bytes_xmit;
>      ram_addr_t current_addr;
> -    MemoryRegion *mr = block->mr;
>      uint8_t *p;
>      int ret;
>      bool send_async = true;
>  
> -    p = memory_region_get_ram_ptr(mr) + offset;
> +    p = block->host + offset;
>  
>      /* In doubt sent page as normal */
>      bytes_xmit = 0;
> @@ -744,7 +743,7 @@ static int do_compress_ram_page(CompressParam *param)
>      RAMBlock *block = param->block;
>      ram_addr_t offset = param->offset;
>  
> -    p = memory_region_get_ram_ptr(block->mr) + (offset & TARGET_PAGE_MASK);
> +    p = block->host + (offset & TARGET_PAGE_MASK);
>  
>      bytes_sent = save_page_header(param->file, block, offset |
>                                    RAM_SAVE_FLAG_COMPRESS_PAGE);
> @@ -852,11 +851,10 @@ static int ram_save_compressed_page(QEMUFile *f, RAMBlock *block,
>  {
>      int pages = -1;
>      uint64_t bytes_xmit;
> -    MemoryRegion *mr = block->mr;
>      uint8_t *p;
>      int ret;
>  
> -    p = memory_region_get_ram_ptr(mr) + offset;
> +    p = block->host + offset;
>  
>      bytes_xmit = 0;
>      ret = ram_control_save_page(f, block->offset,
> @@ -929,14 +927,12 @@ static int ram_find_and_save_block(QEMUFile *f, bool last_stage,
>      ram_addr_t offset = last_offset;
>      bool complete_round = false;
>      int pages = 0;
> -    MemoryRegion *mr;
>  
>      if (!block)
>          block = QLIST_FIRST_RCU(&ram_list.blocks);
>  
>      while (true) {
> -        mr = block->mr;
> -        offset = migration_bitmap_find_and_reset_dirty(mr, offset);
> +        offset = migration_bitmap_find_and_reset_dirty(block, offset);
>          if (complete_round && block == last_seen_block &&
>              offset >= last_offset) {
>              break;
> @@ -1344,7 +1340,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
>              return NULL;
>          }
>  
> -        return memory_region_get_ram_ptr(block->mr) + offset;
> +        return block->host + offset;
>      }
>  
>      len = qemu_get_byte(f);
> @@ -1354,7 +1350,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
>      QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
>          if (!strncmp(id, block->idstr, sizeof(id)) &&
>              block->max_length > offset) {
> -            return memory_region_get_ram_ptr(block->mr) + offset;
> +            return block->host + offset;
>          }
>      }
>  
> 

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

It would be nice in a follow-up patch to move RAMBlock-related
definitions into include/exec/ram_addr.h.

Paolo

  reply	other threads:[~2015-08-13 12:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-13 10:51 [Qemu-devel] [PATCH 0/5] Migration cleanups Dr. David Alan Gilbert (git)
2015-08-13 10:51 ` [Qemu-devel] [PATCH 1/5] migration/ram.c: Use RAMBlock rather than MemoryRegion Dr. David Alan Gilbert (git)
2015-08-13 12:46   ` Paolo Bonzini [this message]
2015-09-15 10:43   ` Amit Shah
2015-08-13 10:51 ` [Qemu-devel] [PATCH 2/5] Split out end of migration code from migration_thread Dr. David Alan Gilbert (git)
2015-08-13 12:14   ` zhanghailiang
2015-09-15 11:12   ` Amit Shah
2015-08-13 10:51 ` [Qemu-devel] [PATCH 3/5] Init page sizes in qtest Dr. David Alan Gilbert (git)
2015-08-13 10:51 ` [Qemu-devel] [PATCH 4/5] migration: size_t'ify some of qemu-file Dr. David Alan Gilbert (git)
2015-08-13 12:15   ` zhanghailiang
2015-09-15 11:39   ` Amit Shah
2015-08-13 10:51 ` [Qemu-devel] [PATCH 5/5] migration: qemu-file more size_t'ifying Dr. David Alan Gilbert (git)
2015-08-13 12:15   ` zhanghailiang
2015-09-15 11:42   ` Amit Shah

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=55CC91AB.4010904@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.