qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: qemu-devel@nongnu.org
Cc: imammedo@redhat.com,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>
Subject: [Qemu-devel] [PATCH] hostmem: no need to check for host_memory_backend_mr_inited() in alloc()
Date: Thu, 30 Aug 2018 19:50:19 +0200	[thread overview]
Message-ID: <20180830175019.16939-1-marcandre.lureau@redhat.com> (raw)

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>
---
 backends/hostmem-file.c  | 2 +-
 backends/hostmem-memfd.c | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
index 2476dcb435..5cd5fa75a7 100644
--- a/backends/hostmem-file.c
+++ b/backends/hostmem-file.c
@@ -54,7 +54,7 @@ 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));
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 ?
-- 
2.19.0.rc0.48.gb9dfa238d5

             reply	other threads:[~2018-08-30 17:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-30 17:50 Marc-André Lureau [this message]
2018-08-30 19:09 ` [Qemu-devel] [PATCH] hostmem: no need to check for host_memory_backend_mr_inited() in alloc() Eduardo Habkost
2018-08-31  6:53   ` Igor Mammedov

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=20180830175019.16939-1-marcandre.lureau@redhat.com \
    --to=marcandre.lureau@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@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).