qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC v2 0/2] migration: Tally pre-copy, downtime and post-copy bytes independently
@ 2021-12-20  9:34 David Edmondson
  2021-12-20  9:34 ` [RFC v2 1/2] migration: Introduce ram_transferred_add() David Edmondson
  2021-12-20  9:34 ` [RFC v2 2/2] migration: Tally pre-copy, downtime and post-copy bytes independently David Edmondson
  0 siblings, 2 replies; 5+ messages in thread
From: David Edmondson @ 2021-12-20  9:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: David Edmondson, Juan Quintela, Eric Blake, Markus Armbruster,
	Dr. David Alan Gilbert

When examining a report of poor migration behaviour, it would often be
useful to understand how much data was transferred in different phases
of the migration process.

For example, if the downtime limit is exceeded, to know how much data
was transferred during the downtime.

RFC because the name "ram_transferred_add" doesn't seem great, and I'm
unsure whether the tests to determine the phase in the second patch
are the most appropriate.

v2:
- ram_transferred_add() should be static (Philippe)
- Document the new MigrationStats fields (dme)

David Edmondson (2):
  migration: Introduce ram_transferred_add()
  migration: Tally pre-copy, downtime and post-copy bytes independently

 migration/migration.c |  3 +++
 migration/ram.c       | 30 +++++++++++++++++++++---------
 monitor/hmp-cmds.c    | 12 ++++++++++++
 qapi/migration.json   | 13 ++++++++++++-
 4 files changed, 48 insertions(+), 10 deletions(-)

-- 
2.33.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RFC v2 1/2] migration: Introduce ram_transferred_add()
  2021-12-20  9:34 [RFC v2 0/2] migration: Tally pre-copy, downtime and post-copy bytes independently David Edmondson
@ 2021-12-20  9:34 ` David Edmondson
  2021-12-21  8:37   ` Philippe Mathieu-Daudé
  2021-12-20  9:34 ` [RFC v2 2/2] migration: Tally pre-copy, downtime and post-copy bytes independently David Edmondson
  1 sibling, 1 reply; 5+ messages in thread
From: David Edmondson @ 2021-12-20  9:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: David Edmondson, Juan Quintela, Eric Blake, Markus Armbruster,
	Dr. David Alan Gilbert

...and use it.

Signed-off-by: David Edmondson <david.edmondson@oracle.com>
---
 migration/ram.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index 57efa67f20..bd53e50a7f 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -386,6 +386,11 @@ uint64_t ram_bytes_remaining(void)
 
 MigrationStats ram_counters;
 
+static void ram_transferred_add(uint64_t bytes)
+{
+    ram_counters.transferred += bytes;
+}
+
 /* used by the search for pages to send */
 struct PageSearchStatus {
     /* Current block being searched */
@@ -767,7 +772,7 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data,
      * RAM_SAVE_FLAG_CONTINUE.
      */
     xbzrle_counters.bytes += bytes_xbzrle - 8;
-    ram_counters.transferred += bytes_xbzrle;
+    ram_transferred_add(bytes_xbzrle);
 
     return 1;
 }
@@ -1198,7 +1203,7 @@ static int save_zero_page(RAMState *rs, RAMBlock *block, ram_addr_t offset)
 
     if (len) {
         ram_counters.duplicate++;
-        ram_counters.transferred += len;
+        ram_transferred_add(len);
         return 1;
     }
     return -1;
@@ -1234,7 +1239,7 @@ static bool control_save_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,
     }
 
     if (bytes_xmit) {
-        ram_counters.transferred += bytes_xmit;
+        ram_transferred_add(bytes_xmit);
         *pages = 1;
     }
 
@@ -1265,8 +1270,8 @@ static bool control_save_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,
 static int save_normal_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,
                             uint8_t *buf, bool async)
 {
-    ram_counters.transferred += save_page_header(rs, rs->f, block,
-                                                 offset | RAM_SAVE_FLAG_PAGE);
+    ram_transferred_add(save_page_header(rs, rs->f, block,
+                                         offset | RAM_SAVE_FLAG_PAGE));
     if (async) {
         qemu_put_buffer_async(rs->f, buf, TARGET_PAGE_SIZE,
                               migrate_release_ram() &
@@ -1274,7 +1279,7 @@ static int save_normal_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,
     } else {
         qemu_put_buffer(rs->f, buf, TARGET_PAGE_SIZE);
     }
-    ram_counters.transferred += TARGET_PAGE_SIZE;
+    ram_transferred_add(TARGET_PAGE_SIZE);
     ram_counters.normal++;
     return 1;
 }
@@ -1373,7 +1378,7 @@ exit:
 static void
 update_compress_thread_counts(const CompressParam *param, int bytes_xmit)
 {
-    ram_counters.transferred += bytes_xmit;
+    ram_transferred_add(bytes_xmit);
 
     if (param->zero_page) {
         ram_counters.duplicate++;
@@ -2298,7 +2303,7 @@ void acct_update_position(QEMUFile *f, size_t size, bool zero)
         ram_counters.duplicate += pages;
     } else {
         ram_counters.normal += pages;
-        ram_counters.transferred += size;
+        ram_transferred_add(size);
         qemu_update_position(f, size);
     }
 }
@@ -3133,7 +3138,7 @@ out:
         multifd_send_sync_main(rs->f);
         qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
         qemu_fflush(f);
-        ram_counters.transferred += 8;
+        ram_transferred_add(8);
 
         ret = qemu_file_get_error(f);
     }
-- 
2.33.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RFC v2 2/2] migration: Tally pre-copy, downtime and post-copy bytes independently
  2021-12-20  9:34 [RFC v2 0/2] migration: Tally pre-copy, downtime and post-copy bytes independently David Edmondson
  2021-12-20  9:34 ` [RFC v2 1/2] migration: Introduce ram_transferred_add() David Edmondson
@ 2021-12-20  9:34 ` David Edmondson
  2021-12-21  8:28   ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 5+ messages in thread
From: David Edmondson @ 2021-12-20  9:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: David Edmondson, Juan Quintela, Eric Blake, Markus Armbruster,
	Dr. David Alan Gilbert

Provide information on the number of bytes copied in the pre-copy,
downtime and post-copy phases of migration.

Signed-off-by: David Edmondson <david.edmondson@oracle.com>
---
 migration/migration.c |  3 +++
 migration/ram.c       |  7 +++++++
 monitor/hmp-cmds.c    | 12 ++++++++++++
 qapi/migration.json   | 13 ++++++++++++-
 4 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/migration/migration.c b/migration/migration.c
index 3de11ae921..3950510be7 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1013,6 +1013,9 @@ static void populate_ram_info(MigrationInfo *info, MigrationState *s)
     info->ram->page_size = page_size;
     info->ram->multifd_bytes = ram_counters.multifd_bytes;
     info->ram->pages_per_second = s->pages_per_second;
+    info->ram->precopy_bytes = ram_counters.precopy_bytes;
+    info->ram->downtime_bytes = ram_counters.downtime_bytes;
+    info->ram->postcopy_bytes = ram_counters.postcopy_bytes;
 
     if (migrate_use_xbzrle()) {
         info->has_xbzrle_cache = true;
diff --git a/migration/ram.c b/migration/ram.c
index bd53e50a7f..389868c988 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -388,6 +388,13 @@ MigrationStats ram_counters;
 
 static void ram_transferred_add(uint64_t bytes)
 {
+    if (runstate_is_running()) {
+        ram_counters.precopy_bytes += bytes;
+    } else if (migration_in_postcopy()) {
+        ram_counters.postcopy_bytes += bytes;
+    } else {
+        ram_counters.downtime_bytes += bytes;
+    }
     ram_counters.transferred += bytes;
 }
 
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 9c91bf93e9..6049772178 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -293,6 +293,18 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
             monitor_printf(mon, "postcopy request count: %" PRIu64 "\n",
                            info->ram->postcopy_requests);
         }
+        if (info->ram->precopy_bytes) {
+            monitor_printf(mon, "precopy ram: %" PRIu64 " kbytes\n",
+                           info->ram->precopy_bytes >> 10);
+        }
+        if (info->ram->downtime_bytes) {
+            monitor_printf(mon, "downtime ram: %" PRIu64 " kbytes\n",
+                           info->ram->downtime_bytes >> 10);
+        }
+        if (info->ram->postcopy_bytes) {
+            monitor_printf(mon, "postcopy ram: %" PRIu64 " kbytes\n",
+                           info->ram->postcopy_bytes >> 10);
+        }
     }
 
     if (info->has_disk) {
diff --git a/qapi/migration.json b/qapi/migration.json
index bbfd48cf0b..5975a0e104 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -46,6 +46,15 @@
 # @pages-per-second: the number of memory pages transferred per second
 #                    (Since 4.0)
 #
+# @precopy-bytes: The number of bytes sent in the pre-copy phase
+#                 (since 7.0).
+#
+# @downtime-bytes: The number of bytes sent while the guest is paused
+#                  (since 7.0).
+#
+# @postcopy-bytes: The number of bytes sent during the post-copy phase
+#                  (since 7.0).
+#
 # Since: 0.14
 ##
 { 'struct': 'MigrationStats',
@@ -54,7 +63,9 @@
            'normal-bytes': 'int', 'dirty-pages-rate' : 'int',
            'mbps' : 'number', 'dirty-sync-count' : 'int',
            'postcopy-requests' : 'int', 'page-size' : 'int',
-           'multifd-bytes' : 'uint64', 'pages-per-second' : 'uint64' } }
+           'multifd-bytes' : 'uint64', 'pages-per-second' : 'uint64',
+           'precopy-bytes' : 'uint64', 'downtime-bytes' : 'uint64',
+           'postcopy-bytes' : 'uint64' } }
 
 ##
 # @XBZRLECacheStats:
-- 
2.33.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RFC v2 2/2] migration: Tally pre-copy, downtime and post-copy bytes independently
  2021-12-20  9:34 ` [RFC v2 2/2] migration: Tally pre-copy, downtime and post-copy bytes independently David Edmondson
@ 2021-12-21  8:28   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-12-21  8:28 UTC (permalink / raw)
  To: David Edmondson, qemu-devel
  Cc: Eric Blake, Markus Armbruster, Dr. David Alan Gilbert,
	Juan Quintela

On 12/20/21 10:34, David Edmondson wrote:
> Provide information on the number of bytes copied in the pre-copy,
> downtime and post-copy phases of migration.
> 
> Signed-off-by: David Edmondson <david.edmondson@oracle.com>
> ---
>  migration/migration.c |  3 +++
>  migration/ram.c       |  7 +++++++
>  monitor/hmp-cmds.c    | 12 ++++++++++++
>  qapi/migration.json   | 13 ++++++++++++-
>  4 files changed, 34 insertions(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC v2 1/2] migration: Introduce ram_transferred_add()
  2021-12-20  9:34 ` [RFC v2 1/2] migration: Introduce ram_transferred_add() David Edmondson
@ 2021-12-21  8:37   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-12-21  8:37 UTC (permalink / raw)
  To: David Edmondson, qemu-devel
  Cc: Eric Blake, Markus Armbruster, Dr. David Alan Gilbert,
	Juan Quintela

On 12/20/21 10:34, David Edmondson wrote:
> ...and use it.

FYI Not all mails readers / git tools display subject along
with content, so it is more helpful to rewrite the subject.

> Signed-off-by: David Edmondson <david.edmondson@oracle.com>
> ---
>  migration/ram.c | 23 ++++++++++++++---------
>  1 file changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/migration/ram.c b/migration/ram.c
> index 57efa67f20..bd53e50a7f 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -386,6 +386,11 @@ uint64_t ram_bytes_remaining(void)
>  
>  MigrationStats ram_counters;
>  
> +static void ram_transferred_add(uint64_t bytes)
> +{
> +    ram_counters.transferred += bytes;
> +}

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-12-21  8:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-20  9:34 [RFC v2 0/2] migration: Tally pre-copy, downtime and post-copy bytes independently David Edmondson
2021-12-20  9:34 ` [RFC v2 1/2] migration: Introduce ram_transferred_add() David Edmondson
2021-12-21  8:37   ` Philippe Mathieu-Daudé
2021-12-20  9:34 ` [RFC v2 2/2] migration: Tally pre-copy, downtime and post-copy bytes independently David Edmondson
2021-12-21  8:28   ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).