qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pankaj Gupta <pagupta@redhat.com>
To: Yi Zhang <yi.z.zhang@linux.intel.com>
Cc: xiaoguangrong eric <xiaoguangrong.eric@gmail.com>,
	stefanha@redhat.com, pbonzini@redhat.com,
	yu c zhang <yu.c.zhang@linux.intel.com>,
	richardw yang <richardw.yang@linux.intel.com>,
	mst@redhat.com, ehabkost@redhat.com, imammedo@redhat.com,
	dan j williams <dan.j.williams@intel.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v11 1/3] util/mmap-alloc: Add a 'is_pmem' parameter to qemu_ram_mmap
Date: Tue, 29 Jan 2019 01:58:09 -0500 (EST)	[thread overview]
Message-ID: <1615390597.67462150.1548745089034.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <8d5b28ca0350dfb6a0313f06c6ceb0f15201c8d7.1548771590.git.yi.z.zhang@linux.intel.com>


> 
> From: Zhang Yi <yi.z.zhang@linux.intel.com>
> 
> besides the existing 'shared' flags, we are going to add
> 'is_pmem' to qemu_ram_mmap(), which indicated the memory backend
> file is a persist memory.
> 
> Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
> Signed-off-by: Zhang Yi <yi.z.zhang@linux.intel.com>
> ---
>  exec.c                    |  2 +-
>  include/qemu/mmap-alloc.h | 21 ++++++++++++++++++++-
>  util/mmap-alloc.c         |  6 +++++-
>  util/oslib-posix.c        |  2 +-
>  4 files changed, 27 insertions(+), 4 deletions(-)
> 
> diff --git a/exec.c b/exec.c
> index bb6170d..27cea52 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1860,7 +1860,7 @@ static void *file_ram_alloc(RAMBlock *block,
>      }
>  
>      area = qemu_ram_mmap(fd, memory, block->mr->align,
> -                         block->flags & RAM_SHARED);
> +                         block->flags & RAM_SHARED, block->flags &
> RAM_PMEM);
>      if (area == MAP_FAILED) {
>          error_setg_errno(errp, errno,
>                           "unable to map backing store for guest RAM");
> diff --git a/include/qemu/mmap-alloc.h b/include/qemu/mmap-alloc.h
> index 50385e3..190688a 100644
> --- a/include/qemu/mmap-alloc.h
> +++ b/include/qemu/mmap-alloc.h
> @@ -7,7 +7,26 @@ size_t qemu_fd_getpagesize(int fd);
>  
>  size_t qemu_mempath_getpagesize(const char *mem_path);
>  
> -void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared);
> +/**
> + * qemu_ram_mmap: mmap the specified file or device.
> + *
> + * Parameters:
> + *  @fd: the file or the device to mmap
> + *  @size: the number of bytes to be mmaped
> + *  @align: if not zero, specify the alignment of the starting mapping
> address;
> + *          otherwise, the alignment in use will be determined by QEMU.
> + *  @shared: map has RAM_SHARED flag.
> + *  @is_pmem: map has RAM_PMEM flag.
> + *
> + * Return:
> + *  On success, return a pointer to the mapped area.
> + *  On failure, return MAP_FAILED.
> + */
> +void *qemu_ram_mmap(int fd,
> +                    size_t size,
> +                    size_t align,
> +                    bool shared,
> +                    bool is_pmem);
>  
>  void qemu_ram_munmap(void *ptr, size_t size);
>  
> diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c
> index fd329ec..97bbeed 100644
> --- a/util/mmap-alloc.c
> +++ b/util/mmap-alloc.c
> @@ -75,7 +75,11 @@ size_t qemu_mempath_getpagesize(const char *mem_path)
>      return getpagesize();
>  }
>  
> -void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared)
> +void *qemu_ram_mmap(int fd,
> +                    size_t size,
> +                    size_t align,
> +                    bool shared,
> +                    bool is_pmem)
>  {
>      /*
>       * Note: this always allocates at least one extra page of virtual
>       address
> diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> index fbd0dc8..040937f 100644
> --- a/util/oslib-posix.c
> +++ b/util/oslib-posix.c
> @@ -203,7 +203,7 @@ void *qemu_memalign(size_t alignment, size_t size)
>  void *qemu_anon_ram_alloc(size_t size, uint64_t *alignment, bool shared)
>  {
>      size_t align = QEMU_VMALLOC_ALIGN;
> -    void *ptr = qemu_ram_mmap(-1, size, align, shared);
> +    void *ptr = qemu_ram_mmap(-1, size, align, shared, false);
>  
>      if (ptr == MAP_FAILED) {
>          return NULL;
> --
> 2.7.4

Looks good to me.

Reviewed-by: pagupta@redhat.com

> 
> 
> 

  reply	other threads:[~2019-01-29  6:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-29 14:48 [Qemu-devel] [PATCH v11 0/3] support MAP_SYNC for memory-backend-file Zhang, Yi
2019-01-29 14:49 ` [Qemu-devel] [PATCH v11 1/3] util/mmap-alloc: Add a 'is_pmem' parameter to qemu_ram_mmap Zhang, Yi
2019-01-29  6:58   ` Pankaj Gupta [this message]
2019-01-29 14:49 ` [Qemu-devel] [PATCH v11 2/3] util/mmap-alloc: support MAP_SYNC in qemu_ram_mmap() Zhang, Yi
2019-01-29  6:55   ` Pankaj Gupta
2019-01-30 11:15     ` Yi Zhang
2019-01-29 13:50   ` Michael S. Tsirkin
2019-01-30 10:36     ` Yi Zhang
2019-01-30  2:28       ` Michael S. Tsirkin
2019-01-29 14:49 ` [Qemu-devel] [PATCH v11 3/3] docs: Added MAP_SYNC documentation Zhang, Yi
2019-01-29 14:09   ` Michael S. Tsirkin
2019-01-30 11:20     ` Yi Zhang

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=1615390597.67462150.1548745089034.JavaMail.zimbra@redhat.com \
    --to=pagupta@redhat.com \
    --cc=dan.j.williams@intel.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richardw.yang@linux.intel.com \
    --cc=stefanha@redhat.com \
    --cc=xiaoguangrong.eric@gmail.com \
    --cc=yi.z.zhang@linux.intel.com \
    --cc=yu.c.zhang@linux.intel.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).