qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Gonglei <arei.gonglei@huawei.com>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, peter.huangpeng@huawei.com
Subject: Re: [Qemu-devel] [PATCH 1/3] exec: store RAMBlock pointer into memory region
Date: Mon, 22 Feb 2016 10:45:35 +0800	[thread overview]
Message-ID: <20160222024535.GA25662@ad.usersys.redhat.com> (raw)
In-Reply-To: <1455935721-8804-2-git-send-email-arei.gonglei@huawei.com>

On Sat, 02/20 10:35, Gonglei wrote:
> Each RAM memory region has a unique corresponding RAMBlock.
> In the current realization, the memory region only stored
> the ram_addr which means the offset of RAM address space,
> We need to qurey the global ram.list to find the ram block
> by ram_addr if we want to get the ram block, which is very
> expensive.
> 
> Now, we store the RAMBlock pointer into memory region
> structure. So, if we know the mr, we can easily get the
> RAMBlock.
> 
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
>  exec.c                | 2 ++
>  include/exec/memory.h | 1 +
>  memory.c              | 1 +
>  3 files changed, 4 insertions(+)
> 
> diff --git a/exec.c b/exec.c
> index 1f24500..e29e369 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1717,6 +1717,8 @@ ram_addr_t qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size,
>          error_propagate(errp, local_err);
>          return -1;
>      }
> +    /* store the ram block pointer into memroy region */

The comment is superfluous IMHO, the code is quite self-explanatory.

> +    mr->ram_block = new_block;
>      return addr;
>  }
>  
> diff --git a/include/exec/memory.h b/include/exec/memory.h
> index c92734a..23e2e3e 100644
> --- a/include/exec/memory.h
> +++ b/include/exec/memory.h
> @@ -172,6 +172,7 @@ struct MemoryRegion {
>      bool global_locking;
>      uint8_t dirty_log_mask;
>      ram_addr_t ram_addr;
> +    void *ram_block;   /* RAMBlock pointer */

Why not add

    typedef struct RAMBlock RAMBlock;

then

    RAMBlock *ram_block;

?

>      Object *owner;
>      const MemoryRegionIOMMUOps *iommu_ops;
>  
> diff --git a/memory.c b/memory.c
> index 09041ed..b4451dd 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -912,6 +912,7 @@ void memory_region_init(MemoryRegion *mr,
>      }
>      mr->name = g_strdup(name);
>      mr->owner = owner;
> +    mr->ram_block = NULL;
>  
>      if (name) {
>          char *escaped_name = memory_region_escape_name(name);
> -- 
> 1.8.5.2
> 
> 
> 

  reply	other threads:[~2016-02-22  2:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-20  2:35 [Qemu-devel] [PATCH 0/3] memory: an optimization Gonglei
2016-02-20  2:35 ` [Qemu-devel] [PATCH 1/3] exec: store RAMBlock pointer into memory region Gonglei
2016-02-22  2:45   ` Fam Zheng [this message]
2016-02-22  3:28     ` Gonglei (Arei)
2016-02-20  2:35 ` [Qemu-devel] [PATCH 2/3] memory: optimize qemu_get_ram_ptr and qemu_ram_ptr_length Gonglei
2016-02-20  2:35 ` [Qemu-devel] [PATCH 3/3] memory: Remove the superfluous code Gonglei
2016-02-20  9:47 ` [Qemu-devel] [PATCH 0/3] memory: an optimization Paolo Bonzini
2016-02-20 10:34   ` Gonglei (Arei)

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=20160222024535.GA25662@ad.usersys.redhat.com \
    --to=famz@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.huangpeng@huawei.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).