From: Igor Mammedov <imammedo@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org, Eduardo Habkost <ehabkost@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2] hostmem: no need to check for host_memory_backend_mr_inited() in alloc()
Date: Thu, 13 Sep 2018 13:45:35 +0200 [thread overview]
Message-ID: <20180913134535.4b19e520@redhat.com> (raw)
In-Reply-To: <20180910134946.16773-1-marcandre.lureau@redhat.com>
On Mon, 10 Sep 2018 17:49:46 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> memfd_backend_memory_alloc/file_backend_memory_alloc both needlessly
> are are calling host_memory_backend_mr_inited() which creates an
> illusion that alloc could be called multiple times but it isn't, it's
> called once from UserCreatable complete().
>
> Suggested-by: Igor Mammedov <imammedo@redhat.com>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
> ---
> backends/hostmem-file.c | 24 ++++++++++++------------
> backends/hostmem-memfd.c | 4 ----
> 2 files changed, 12 insertions(+), 16 deletions(-)
>
> v2:
> - cosmetic: remove extra indentation in backends/hostmem-file.c
>
> diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
> index 2476dcb435..09b21280ce 100644
> --- a/backends/hostmem-file.c
> +++ b/backends/hostmem-file.c
> @@ -42,6 +42,9 @@ static void
> file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
> {
> HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(backend);
> +#ifdef CONFIG_LINUX
> + gchar *path;
> +#endif
>
> if (!backend->size) {
> error_setg(errp, "can't create backend with size 0");
> @@ -54,18 +57,15 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
> #ifndef CONFIG_LINUX
> error_setg(errp, "-mem-path not supported on this host");
> #else
> - if (!host_memory_backend_mr_inited(backend)) {
> - gchar *path;
> - backend->force_prealloc = mem_prealloc;
> - path = object_get_canonical_path(OBJECT(backend));
> - memory_region_init_ram_from_file(&backend->mr, OBJECT(backend),
> - path,
> - backend->size, fb->align,
> - (backend->share ? RAM_SHARED : 0) |
> - (fb->is_pmem ? RAM_PMEM : 0),
> - fb->mem_path, errp);
> - g_free(path);
> - }
> + backend->force_prealloc = mem_prealloc;
> + path = object_get_canonical_path(OBJECT(backend));
> + memory_region_init_ram_from_file(&backend->mr, OBJECT(backend),
> + path,
> + backend->size, fb->align,
> + (backend->share ? RAM_SHARED : 0) |
> + (fb->is_pmem ? RAM_PMEM : 0),
> + fb->mem_path, errp);
> + g_free(path);
> #endif
> }
>
> diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c
> index abd52364db..7184918112 100644
> --- a/backends/hostmem-memfd.c
> +++ b/backends/hostmem-memfd.c
> @@ -44,10 +44,6 @@ memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
> return;
> }
>
> - if (host_memory_backend_mr_inited(backend)) {
> - return;
> - }
> -
> backend->force_prealloc = mem_prealloc;
> fd = qemu_memfd_create(TYPE_MEMORY_BACKEND_MEMFD, backend->size,
> m->hugetlb, m->hugetlbsize, m->seal ?
prev parent reply other threads:[~2018-09-13 11:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-10 13:49 [Qemu-devel] [PATCH v2] hostmem: no need to check for host_memory_backend_mr_inited() in alloc() Marc-André Lureau
2018-09-13 11:45 ` Igor Mammedov [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=20180913134535.4b19e520@redhat.com \
--to=imammedo@redhat.com \
--cc=ehabkost@redhat.com \
--cc=marcandre.lureau@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 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.