[PATCH RFC 03/21] physmem: Add qemu_ram_is_hugetlb()

Peter Xu posted 21 patches 3 years ago
Maintainers: David Hildenbrand <david@redhat.com>, Igor Mammedov <imammedo@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Peter Xu <peterx@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Cornelia Huck <cohuck@redhat.com>, Juan Quintela <quintela@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>
[PATCH RFC 03/21] physmem: Add qemu_ram_is_hugetlb()
Posted by Peter Xu 3 years ago
Returns true for a hugetlbfs mapping, false otherwise.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 include/exec/cpu-common.h | 1 +
 softmmu/physmem.c         | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index 6feaa40ca7..94452aa17f 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -95,6 +95,7 @@ void qemu_ram_unset_migratable(RAMBlock *rb);
 int qemu_ram_get_fd(RAMBlock *rb);
 
 size_t qemu_ram_pagesize(RAMBlock *block);
+bool qemu_ram_is_hugetlb(RAMBlock *rb);
 size_t qemu_ram_pagesize_largest(void);
 
 /**
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index edec095c7a..a4fb129d8f 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -1798,6 +1798,11 @@ size_t qemu_ram_pagesize(RAMBlock *rb)
     return rb->page_size;
 }
 
+bool qemu_ram_is_hugetlb(RAMBlock *rb)
+{
+    return rb->page_size > qemu_real_host_page_size();
+}
+
 /* Returns the largest size of page in use */
 size_t qemu_ram_pagesize_largest(void)
 {
-- 
2.37.3
Re: [PATCH RFC 03/21] physmem: Add qemu_ram_is_hugetlb()
Posted by Juan Quintela 3 years ago
Peter Xu <peterx@redhat.com> wrote:
> Returns true for a hugetlbfs mapping, false otherwise.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>
Re: [PATCH RFC 03/21] physmem: Add qemu_ram_is_hugetlb()
Posted by Dr. David Alan Gilbert 3 years ago
* Peter Xu (peterx@redhat.com) wrote:
> Returns true for a hugetlbfs mapping, false otherwise.
> 
> Signed-off-by: Peter Xu <peterx@redhat.com>

Yeh OK, it feels a little delecate perhaps if anything else
ever allows large mappings.


Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  include/exec/cpu-common.h | 1 +
>  softmmu/physmem.c         | 5 +++++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
> index 6feaa40ca7..94452aa17f 100644
> --- a/include/exec/cpu-common.h
> +++ b/include/exec/cpu-common.h
> @@ -95,6 +95,7 @@ void qemu_ram_unset_migratable(RAMBlock *rb);
>  int qemu_ram_get_fd(RAMBlock *rb);
>  
>  size_t qemu_ram_pagesize(RAMBlock *block);
> +bool qemu_ram_is_hugetlb(RAMBlock *rb);
>  size_t qemu_ram_pagesize_largest(void);
>  
>  /**
> diff --git a/softmmu/physmem.c b/softmmu/physmem.c
> index edec095c7a..a4fb129d8f 100644
> --- a/softmmu/physmem.c
> +++ b/softmmu/physmem.c
> @@ -1798,6 +1798,11 @@ size_t qemu_ram_pagesize(RAMBlock *rb)
>      return rb->page_size;
>  }
>  
> +bool qemu_ram_is_hugetlb(RAMBlock *rb)
> +{
> +    return rb->page_size > qemu_real_host_page_size();
> +}
> +
>  /* Returns the largest size of page in use */
>  size_t qemu_ram_pagesize_largest(void)
>  {
> -- 
> 2.37.3
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK