diff mbox series

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

Message ID 20230117220914.2062125-4-peterx@redhat.com (mailing list archive)
State New, archived
Headers show
Series migration: Support hugetlb doublemaps | expand

Commit Message

Peter Xu Jan. 17, 2023, 10:08 p.m. UTC
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(+)

Comments

Dr. David Alan Gilbert Jan. 18, 2023, 12:02 p.m. UTC | #1
* 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
>
Juan Quintela Jan. 30, 2023, 5 a.m. UTC | #2
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>
diff mbox series

Patch

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)
 {