diff mbox series

[RFC,06/21] madvise: Add QEMU_MADV_COLLAPSE

Message ID 20230117220914.2062125-7-peterx@redhat.com
State New
Headers show
Series migration: Support hugetlb doublemaps | expand

Commit Message

Peter Xu Jan. 17, 2023, 10:08 p.m. UTC
MADV_COLLAPSE is a new madvise() on Linux.  Define it.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 include/qemu/madvise.h | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Dr. David Alan Gilbert Jan. 18, 2023, 6:51 p.m. UTC | #1
* Peter Xu (peterx@redhat.com) wrote:
> MADV_COLLAPSE is a new madvise() on Linux.  Define it.

I'd probably have merged this with the MADV_SPLIT one since they go
together; but also, it would be good in the commit message
for Qemu to include either the definition or a pointer to the kernel
definiton of them.

Dave

> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  include/qemu/madvise.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/include/qemu/madvise.h b/include/qemu/madvise.h
> index 3dddd25065..794e5fb0a7 100644
> --- a/include/qemu/madvise.h
> +++ b/include/qemu/madvise.h
> @@ -68,6 +68,11 @@
>  #else
>  #define QEMU_MADV_SPLIT QEMU_MADV_INVALID
>  #endif
> +#ifdef MADV_COLLAPSE
> +#define QEMU_MADV_COLLAPSE MADV_COLLAPSE
> +#else
> +#define QEMU_MADV_COLLAPSE QEMU_MADV_INVALID
> +#endif
>  
>  #elif defined(CONFIG_POSIX_MADVISE)
>  
> @@ -83,6 +88,7 @@
>  #define QEMU_MADV_REMOVE QEMU_MADV_DONTNEED
>  #define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID
>  #define QEMU_MADV_SPLIT QEMU_MADV_INVALID
> +#define QEMU_MADV_COLLAPSE QEMU_MADV_INVALID
>  
>  #else /* no-op */
>  
> @@ -98,6 +104,7 @@
>  #define QEMU_MADV_REMOVE QEMU_MADV_INVALID
>  #define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID
>  #define QEMU_MADV_SPLIT QEMU_MADV_INVALID
> +#define QEMU_MADV_COLLAPSE QEMU_MADV_INVALID
>  
>  #endif
>  
> -- 
> 2.37.3
>
Peter Xu Jan. 18, 2023, 8:21 p.m. UTC | #2
On Wed, Jan 18, 2023 at 06:51:07PM +0000, Dr. David Alan Gilbert wrote:
> * Peter Xu (peterx@redhat.com) wrote:
> > MADV_COLLAPSE is a new madvise() on Linux.  Define it.
> 
> I'd probably have merged this with the MADV_SPLIT one since they go
> together; but also, it would be good in the commit message
> for Qemu to include either the definition or a pointer to the kernel
> definiton of them.

Will do.

I don't have good links for them yet because both of them are still not in
upstream man-page project.  Even THP version of MADV_COLLAPSE man page just
got added into the man-page repository in Nov 2022 so most of the websites
that host man pages won't even have MADV_COLLAPSE..

For now I'll add some more paragraphs trying to explain everything, and
I'll also link to madvise(2) where both of them will be discussed in the
future.

Thanks,
Juan Quintela Jan. 30, 2023, 5:02 a.m. UTC | #3
Peter Xu <peterx@redhat.com> wrote:
> MADV_COLLAPSE is a new madvise() on Linux.  Define it.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>
diff mbox series

Patch

diff --git a/include/qemu/madvise.h b/include/qemu/madvise.h
index 3dddd25065..794e5fb0a7 100644
--- a/include/qemu/madvise.h
+++ b/include/qemu/madvise.h
@@ -68,6 +68,11 @@ 
 #else
 #define QEMU_MADV_SPLIT QEMU_MADV_INVALID
 #endif
+#ifdef MADV_COLLAPSE
+#define QEMU_MADV_COLLAPSE MADV_COLLAPSE
+#else
+#define QEMU_MADV_COLLAPSE QEMU_MADV_INVALID
+#endif
 
 #elif defined(CONFIG_POSIX_MADVISE)
 
@@ -83,6 +88,7 @@ 
 #define QEMU_MADV_REMOVE QEMU_MADV_DONTNEED
 #define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID
 #define QEMU_MADV_SPLIT QEMU_MADV_INVALID
+#define QEMU_MADV_COLLAPSE QEMU_MADV_INVALID
 
 #else /* no-op */
 
@@ -98,6 +104,7 @@ 
 #define QEMU_MADV_REMOVE QEMU_MADV_INVALID
 #define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID
 #define QEMU_MADV_SPLIT QEMU_MADV_INVALID
+#define QEMU_MADV_COLLAPSE QEMU_MADV_INVALID
 
 #endif