qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Thomas Huth <thuth@redhat.com>,
	qemu-devel@nongnu.org, Igor Mammedov <imammedo@redhat.com>
Cc: "David Gibson" <david@gibson.dropbear.id.au>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: Re: [PATCH] backends/hostmem: Fix support of memory-backend-memfd in qemu_maxrampagesize()
Date: Wed, 10 Aug 2022 09:32:23 +0200	[thread overview]
Message-ID: <e1eb8579-079b-fe81-b2df-a342d7ad667a@redhat.com> (raw)
In-Reply-To: <20220810063204.3589543-1-thuth@redhat.com>

On 10.08.22 08:32, Thomas Huth wrote:
> It is currently not possible yet to use "memory-backend-memfd" on s390x
> with hugepages enabled. This problem is caused by qemu_maxrampagesize()
> not taking memory-backend-memfd objects into account yet, so the code
> in s390_memory_init() fails to enable the huge page support there via
> s390_set_max_pagesize(). Fix it by looking at the memory-backend-memfd
> in the host_memory_backend_pagesize() function, too.
> 
> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2116496
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  include/sysemu/hostmem.h |  8 +++++++-
>  backends/hostmem-memfd.c |  2 --
>  backends/hostmem.c       | 27 +++++++++++++++++----------
>  3 files changed, 24 insertions(+), 13 deletions(-)
> 
> diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h
> index 9ff5c16963..d983ae6c01 100644
> --- a/include/sysemu/hostmem.h
> +++ b/include/sysemu/hostmem.h
> @@ -34,10 +34,16 @@ OBJECT_DECLARE_TYPE(HostMemoryBackend, HostMemoryBackendClass,
>  /* hostmem-file.c */
>  /**
>   * @TYPE_MEMORY_BACKEND_FILE:
> - * name of backend that uses mmap on a file descriptor
> + * name of backend that uses mmap on a file
>   */
>  #define TYPE_MEMORY_BACKEND_FILE "memory-backend-file"
>  
> +/* hostmem-memfd.c */
> +/**
> + * @TYPE_MEMORY_BACKEND_MEMFD:
> + * name of backend that uses mmap on a memfd file descriptor
> + */
> +#define TYPE_MEMORY_BACKEND_MEMFD "memory-backend-memfd"
>  
>  /**
>   * HostMemoryBackendClass:
> diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c
> index 3fc85c3db8..1ab2085e49 100644
> --- a/backends/hostmem-memfd.c
> +++ b/backends/hostmem-memfd.c
> @@ -18,8 +18,6 @@
>  #include "qapi/error.h"
>  #include "qom/object.h"
>  
> -#define TYPE_MEMORY_BACKEND_MEMFD "memory-backend-memfd"
> -
>  OBJECT_DECLARE_SIMPLE_TYPE(HostMemoryBackendMemfd, MEMORY_BACKEND_MEMFD)
>  
>  
> diff --git a/backends/hostmem.c b/backends/hostmem.c
> index 624bb7ecd3..ebce887105 100644
> --- a/backends/hostmem.c
> +++ b/backends/hostmem.c
> @@ -306,22 +306,29 @@ bool host_memory_backend_is_mapped(HostMemoryBackend *backend)
>      return backend->is_mapped;
>  }
>  
> -#ifdef __linux__
>  size_t host_memory_backend_pagesize(HostMemoryBackend *memdev)
>  {
> +    size_t pagesize = 0;
> +
> +#ifdef __linux__
>      Object *obj = OBJECT(memdev);
> -    char *path = object_property_get_str(obj, "mem-path", NULL);
> -    size_t pagesize = qemu_mempath_getpagesize(path);
>  
> -    g_free(path);
> +    if (object_dynamic_cast(obj, TYPE_MEMORY_BACKEND_FILE)) {
> +        char *path = object_property_get_str(obj, "mem-path", NULL);
> +        pagesize = qemu_mempath_getpagesize(path);
> +        g_free(path);
> +    } else if (object_dynamic_cast(obj, TYPE_MEMORY_BACKEND_MEMFD) &&
> +               object_property_get_bool(obj, "hugetlb", &error_abort)) {
> +        pagesize = object_property_get_int(obj, "hugetlbsize", &error_abort);
> +    }
> +#endif

Why can't we simply rely on

qemu_ram_pagesize(memdev->mr.ram_block);

?

-- 
Thanks,

David / dhildenb



  reply	other threads:[~2022-08-10  7:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-10  6:32 [PATCH] backends/hostmem: Fix support of memory-backend-memfd in qemu_maxrampagesize() Thomas Huth
2022-08-10  7:32 ` David Hildenbrand [this message]
2022-08-10  8:11   ` Thomas Huth
2022-08-10  8:31     ` David Hildenbrand
2022-08-10  9:20       ` Thomas Huth

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=e1eb8579-079b-fe81-b2df-a342d7ad667a@redhat.com \
    --to=david@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=imammedo@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.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).