All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Gonglei <arei.gonglei@huawei.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, peter.huangpeng@huawei.com
Subject: Re: [Qemu-devel] [PATCH v3 3/3] memory: drop some wrappers that waste cpu cycle
Date: Tue, 17 May 2016 09:50:44 +0800	[thread overview]
Message-ID: <20160517015044.GA21731@ad.usersys.redhat.com> (raw)
In-Reply-To: <1463047636-124524-4-git-send-email-arei.gonglei@huawei.com>

On Thu, 05/12 18:07, Gonglei wrote:
> For better performance, we can use RAMblock
> directly stored in memory_region at present.
> 
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
>  exec.c                  | 33 ++-------------------------------
>  hw/misc/ivshmem.c       |  8 +++++---
>  hw/virtio/vhost-user.c  | 13 ++++++++-----
>  include/exec/ram_addr.h |  4 +---
>  memory.c                |  2 +-
>  5 files changed, 17 insertions(+), 43 deletions(-)
> 
> diff --git a/exec.c b/exec.c
> index 117c9a8..f8de928 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1812,38 +1812,9 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length)
>  }
>  #endif /* !_WIN32 */
>  
> -int qemu_get_ram_fd(ram_addr_t addr)
> +void *qemu_get_ram_block_host_ptr(RAMBlock *ram_block)
>  {
> -    RAMBlock *block;
> -    int fd;
> -
> -    rcu_read_lock();
> -    block = qemu_get_ram_block(addr);
> -    fd = block->fd;
> -    rcu_read_unlock();
> -    return fd;
> -}
> -
> -void qemu_set_ram_fd(ram_addr_t addr, int fd)
> -{
> -    RAMBlock *block;
> -
> -    rcu_read_lock();
> -    block = qemu_get_ram_block(addr);
> -    block->fd = fd;
> -    rcu_read_unlock();
> -}
> -
> -void *qemu_get_ram_block_host_ptr(ram_addr_t addr)
> -{
> -    RAMBlock *block;
> -    void *ptr;
> -
> -    rcu_read_lock();
> -    block = qemu_get_ram_block(addr);
> -    ptr = ramblock_ptr(block, 0);
> -    rcu_read_unlock();
> -    return ptr;
> +    return ramblock_ptr(ram_block, 0);
>  }
>  
>  /* Return a host pointer to ram allocated with qemu_ram_alloc.
> diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
> index e40f23b..1e930fa 100644
> --- a/hw/misc/ivshmem.c
> +++ b/hw/misc/ivshmem.c
> @@ -533,7 +533,9 @@ static void process_msg_shmem(IVShmemState *s, int fd, Error **errp)
>      }
>      memory_region_init_ram_ptr(&s->server_bar2, OBJECT(s),
>                                 "ivshmem.bar2", size, ptr);
> -    qemu_set_ram_fd(memory_region_get_ram_addr(&s->server_bar2), fd);
> +    assert(s->server_bar2.ram_block);
> +    s->server_bar2.ram_block->fd = fd;
> +
>      s->ivshmem_bar2 = &s->server_bar2;
>  }
>  
> @@ -939,8 +941,8 @@ static void ivshmem_exit(PCIDevice *dev)
>                  error_report("Failed to munmap shared memory %s",
>                               strerror(errno));
>              }
> -
> -            fd = qemu_get_ram_fd(memory_region_get_ram_addr(s->ivshmem_bar2));

Maybe this is okay but personally I think it is cleaner to add a
qemu_{set,get}_ramblock_fd pair.

Fam

      reply	other threads:[~2016-05-17  1:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-12 10:07 [Qemu-devel] [PATCH v3 0/3] memory: some little optimizations Gonglei
2016-05-12 10:07 ` [Qemu-devel] [PATCH v3 1/3] memory: drop find_ram_block() Gonglei
2016-05-12 10:07 ` [Qemu-devel] [PATCH v3 2/3] exec: adjust rcu_read_lock requirement Gonglei
2016-05-12 10:07 ` [Qemu-devel] [PATCH v3 3/3] memory: drop some wrappers that waste cpu cycle Gonglei
2016-05-17  1:50   ` Fam Zheng [this message]

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=20160517015044.GA21731@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 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.