[PATCH RFC 06/21] madvise: Add QEMU_MADV_COLLAPSE

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 06/21] madvise: Add QEMU_MADV_COLLAPSE
Posted by Peter Xu 3 years ago
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(+)

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
Re: [PATCH RFC 06/21] madvise: Add QEMU_MADV_COLLAPSE
Posted by Juan Quintela 3 years ago
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>
Re: [PATCH RFC 06/21] madvise: Add QEMU_MADV_COLLAPSE
Posted by Dr. David Alan Gilbert 3 years ago
* 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
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Re: [PATCH RFC 06/21] madvise: Add QEMU_MADV_COLLAPSE
Posted by Peter Xu 3 years ago
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,

-- 
Peter Xu