[PATCH v3 11/33] migration: Remove qemu_host_page_size

Richard Henderson posted 33 patches 10 months, 4 weeks ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Riku Voipio <riku.voipio@iki.fi>, Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, Stefan Berger <stefanb@linux.vnet.ibm.com>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, Laurent Vivier <laurent@vivier.eu>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, David Hildenbrand <david@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Nicholas Piggin <npiggin@gmail.com>, Daniel Henrique Barboza <danielhb413@gmail.com>, "Cédric Le Goater" <clg@kaod.org>, "Alex Bennée" <alex.bennee@linaro.org>, Yoshinori Sato <ysato@users.sourceforge.jp>
There is a newer version of this series
[PATCH v3 11/33] migration: Remove qemu_host_page_size
Posted by Richard Henderson 10 months, 4 weeks ago
Replace with the maximum of the real host page size
and the target page size.  This is an exact replacement.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 migration/ram.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index 8c7886ab79..aa3109fca3 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2936,7 +2936,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
 {
     RAMState **rsp = opaque;
     RAMBlock *block;
-    int ret;
+    int ret, max_hg_page_size;
 
     if (compress_threads_save_setup()) {
         return -1;
@@ -2951,6 +2951,12 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
     }
     (*rsp)->pss[RAM_CHANNEL_PRECOPY].pss_channel = f;
 
+    /*
+     * ??? Mirrors the previous value of qemu_host_page_size,
+     * but is this really what was intended for the migration?
+     */
+    max_hg_page_size = MAX(qemu_real_host_page_size(), TARGET_PAGE_SIZE);
+
     WITH_RCU_READ_LOCK_GUARD() {
         qemu_put_be64(f, ram_bytes_total_with_ignored()
                          | RAM_SAVE_FLAG_MEM_SIZE);
@@ -2959,8 +2965,8 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
             qemu_put_byte(f, strlen(block->idstr));
             qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idstr));
             qemu_put_be64(f, block->used_length);
-            if (migrate_postcopy_ram() && block->page_size !=
-                                          qemu_host_page_size) {
+            if (migrate_postcopy_ram() &&
+                block->page_size != max_hg_page_size) {
                 qemu_put_be64(f, block->page_size);
             }
             if (migrate_ignore_shared()) {
@@ -3794,6 +3800,7 @@ static int parse_ramblock(QEMUFile *f, RAMBlock *block, ram_addr_t length)
     int ret = 0;
     /* ADVISE is earlier, it shows the source has the postcopy capability on */
     bool postcopy_advised = migration_incoming_postcopy_advised();
+    int max_hg_page_size;
 
     assert(block);
 
@@ -3811,9 +3818,16 @@ static int parse_ramblock(QEMUFile *f, RAMBlock *block, ram_addr_t length)
             return ret;
         }
     }
+
+    /*
+     * ??? Mirrors the previous value of qemu_host_page_size,
+     * but is this really what was intended for the migration?
+     */
+    max_hg_page_size = MAX(qemu_real_host_page_size(), TARGET_PAGE_SIZE);
+
     /* For postcopy we need to check hugepage sizes match */
     if (postcopy_advised && migrate_postcopy_ram() &&
-        block->page_size != qemu_host_page_size) {
+        block->page_size != max_hg_page_size) {
         uint64_t remote_page_size = qemu_get_be64(f);
         if (remote_page_size != block->page_size) {
             error_report("Mismatched RAM page size %s "
-- 
2.34.1
Re: [PATCH v3 11/33] migration: Remove qemu_host_page_size
Posted by Ilya Leoshkevich 10 months ago
On Tue, Jan 02, 2024 at 12:57:46PM +1100, Richard Henderson wrote:
> Replace with the maximum of the real host page size
> and the target page size.  This is an exact replacement.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  migration/ram.c | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)

Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Re: [PATCH v3 11/33] migration: Remove qemu_host_page_size
Posted by Pierrick Bouvier 10 months, 3 weeks ago
On 1/2/24 05:57, Richard Henderson wrote:
> Replace with the maximum of the real host page size
> and the target page size.  This is an exact replacement.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   migration/ram.c | 22 ++++++++++++++++++----
>   1 file changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/migration/ram.c b/migration/ram.c
> index 8c7886ab79..aa3109fca3 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -2936,7 +2936,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
>   {
>       RAMState **rsp = opaque;
>       RAMBlock *block;
> -    int ret;
> +    int ret, max_hg_page_size;
>   
>       if (compress_threads_save_setup()) {
>           return -1;
> @@ -2951,6 +2951,12 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
>       }
>       (*rsp)->pss[RAM_CHANNEL_PRECOPY].pss_channel = f;
>   
> +    /*
> +     * ??? Mirrors the previous value of qemu_host_page_size,
> +     * but is this really what was intended for the migration?
> +     */
> +    max_hg_page_size = MAX(qemu_real_host_page_size(), TARGET_PAGE_SIZE);
> +
>       WITH_RCU_READ_LOCK_GUARD() {
>           qemu_put_be64(f, ram_bytes_total_with_ignored()
>                            | RAM_SAVE_FLAG_MEM_SIZE);
> @@ -2959,8 +2965,8 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
>               qemu_put_byte(f, strlen(block->idstr));
>               qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idstr));
>               qemu_put_be64(f, block->used_length);
> -            if (migrate_postcopy_ram() && block->page_size !=
> -                                          qemu_host_page_size) {
> +            if (migrate_postcopy_ram() &&
> +                block->page_size != max_hg_page_size) {
>                   qemu_put_be64(f, block->page_size);
>               }
>               if (migrate_ignore_shared()) {
> @@ -3794,6 +3800,7 @@ static int parse_ramblock(QEMUFile *f, RAMBlock *block, ram_addr_t length)
>       int ret = 0;
>       /* ADVISE is earlier, it shows the source has the postcopy capability on */
>       bool postcopy_advised = migration_incoming_postcopy_advised();
> +    int max_hg_page_size;
>   
>       assert(block);
>   
> @@ -3811,9 +3818,16 @@ static int parse_ramblock(QEMUFile *f, RAMBlock *block, ram_addr_t length)
>               return ret;
>           }
>       }
> +
> +    /*
> +     * ??? Mirrors the previous value of qemu_host_page_size,
> +     * but is this really what was intended for the migration?
> +     */
> +    max_hg_page_size = MAX(qemu_real_host_page_size(), TARGET_PAGE_SIZE);
> +
>       /* For postcopy we need to check hugepage sizes match */
>       if (postcopy_advised && migrate_postcopy_ram() &&
> -        block->page_size != qemu_host_page_size) {
> +        block->page_size != max_hg_page_size) {
>           uint64_t remote_page_size = qemu_get_be64(f);
>           if (remote_page_size != block->page_size) {
>               error_report("Mismatched RAM page size %s "

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>