qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com,
	Igor Mammedov <imammedo@redhat.com>,
	ehabkost@redhat.com
Subject: Re: [Qemu-devel] [PATCH v5 5/6] Add memfd based hostmem
Date: Mon, 23 Oct 2017 12:36:11 +0100	[thread overview]
Message-ID: <20171023113611.GJ16472@redhat.com> (raw)
In-Reply-To: <20171023095910.23202-6-marcandre.lureau@redhat.com>

On Mon, Oct 23, 2017 at 10:59:09AM +0100, Marc-André Lureau wrote:
> Add a new memory backend, similar to hostmem-file, except that it
> doesn't need to create files. It also enforces memory sealing.
> 
> This backend is mainly useful for sharing the memory with other
> processes.
> 
> Note that Linux supports transparent huge-pages of shmem/memfd memory
> since 4.8. It is relatively easier to set up THP than a dedicate
> hugepage mount point by using "madvise" in
> /sys/kernel/mm/transparent_hugepage/shmem_enabled.
> 
> Since 4.14, memfd allows to set hugetlb requirement explicitly.
> 
> Usage:
> -object memory-backend-memfd,id=mem1,size=1G

[snip]

> +static void
> +memfd_backend_class_init(ObjectClass *oc, void *data)
> +{
> +    HostMemoryBackendClass *bc = MEMORY_BACKEND_CLASS(oc);
> +
> +    bc->alloc = memfd_backend_memory_alloc;
> +
> +    object_class_property_add_bool(oc, "hugetlb",
> +                                   memfd_backend_get_hugetlb,
> +                                   memfd_backend_set_hugetlb,
> +                                   &error_abort);

I tend to think that instead of a bool hugetlb, we should take an
integer page size instead eg  hugepagesize=2M instead of hugetlb=true



> diff --git a/qemu-options.hx b/qemu-options.hx
> index 3728e9b4dd..5828caefeb 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -4208,6 +4208,21 @@ that @option{discard-data} is only an optimization, and QEMU
>  might not discard file contents if it aborts unexpectedly or is
>  terminated using SIGKILL.
>  
> +@item -object memory-backend-memfd,id=@var{id},size=@var{size},seal=@var{on|off},hugetlb=@var{on|off}
> +
> +Creates an anonymous memory file backend object, which allows QEMU to
> +share the memory with an external process in some cases (e.g. when
> +using vhost-user). The memory is allocated with memfd and optional
> +sealing. (Linux only)
> +
> +The @option{id} parameter is a unique ID that will be used to
> +reference this memory region when configuring the @option{-numa}
> +argument. The @option{size} option provides the size of the memory
> +region, and accepts common suffixes, eg @option{500M}. The
> +@option{seal} option creates a sealed-file, that will block further
> +resizing the memory ('on' by default). The @option{hugetlb} option
> +specify the file to be created resides in the hugetlbfs filesystem.

This should document that you can't combine sealing and huge pages

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

  reply	other threads:[~2017-10-23 11:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-23  9:59 [Qemu-devel] [PATCH v5 0/6] Add memfd memory backend Marc-André Lureau
2017-10-23  9:59 ` [Qemu-devel] [PATCH v5 1/6] memfd: split qemu_memfd_alloc() Marc-André Lureau
2017-10-23 11:02   ` Philippe Mathieu-Daudé
2017-10-23  9:59 ` [Qemu-devel] [PATCH v5 2/6] memfd: remove needless include Marc-André Lureau
2017-10-23 10:59   ` Philippe Mathieu-Daudé
2017-10-23  9:59 ` [Qemu-devel] [PATCH v5 3/6] memfd: add error argument, instead of perror() Marc-André Lureau
2017-10-23  9:59 ` [Qemu-devel] [PATCH v5 4/6] memfd: add hugetlb support Marc-André Lureau
2017-10-23 10:23   ` Daniel P. Berrange
2017-10-23 11:27     ` Marc-André Lureau
2017-10-23 11:33       ` Daniel P. Berrange
2017-10-23  9:59 ` [Qemu-devel] [PATCH v5 5/6] Add memfd based hostmem Marc-André Lureau
2017-10-23 11:36   ` Daniel P. Berrange [this message]
2017-10-23 11:41     ` Marc-André Lureau
2017-10-23 11:47       ` Daniel P. Berrange
2017-10-23  9:59 ` [Qemu-devel] [PATCH v5 6/6] tests: use memfd in vhost-user-test Marc-André Lureau
2017-10-23 10:26   ` Daniel P. Berrange

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=20171023113611.GJ16472@redhat.com \
    --to=berrange@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.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).