thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-migration-Tally-pre-copy-downtime-and-post-copy-byte.patch

719b13
From 849a82a35629d480cdfa451310b77edd5ee00aa4 Mon Sep 17 00:00:00 2001
719b13
From: David Edmondson <david.edmondson@oracle.com>
719b13
Date: Tue, 21 Dec 2021 09:34:41 +0000
719b13
Subject: [PATCH 28/34] migration: Tally pre-copy, downtime and post-copy bytes
719b13
 independently
719b13
MIME-Version: 1.0
719b13
Content-Type: text/plain; charset=UTF-8
719b13
Content-Transfer-Encoding: 8bit
719b13
719b13
RH-Author: Leonardo Brás <leobras@redhat.com>
719b13
RH-MergeRequest: 185: MSG_ZEROCOPY + Multifd @ rhel8.6
719b13
RH-Commit: [28/34] a6e61ae2f016d020b2456be6087aeb7d4b9f9387
719b13
RH-Bugzilla: 2117252
719b13
RH-Acked-by: quintela1 <quintela@redhat.com>
719b13
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
719b13
RH-Acked-by: Peter Xu <peterx@redhat.com>
719b13
719b13
Provide information on the number of bytes copied in the pre-copy,
719b13
downtime and post-copy phases of migration.
719b13
719b13
Signed-off-by: David Edmondson <david.edmondson@oracle.com>
719b13
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
719b13
Reviewed-by: Juan Quintela <quintela@redhat.com>
719b13
Signed-off-by: Juan Quintela <quintela@redhat.com>
719b13
(cherry picked from commit ae6806688016711bb9ec7541266d76ab511c5e3b)
719b13
Signed-off-by: Leonardo Bras <leobras@redhat.com>
719b13
---
719b13
 migration/migration.c |  3 +++
719b13
 migration/ram.c       |  7 +++++++
719b13
 monitor/hmp-cmds.c    | 12 ++++++++++++
719b13
 qapi/migration.json   | 13 ++++++++++++-
719b13
 4 files changed, 34 insertions(+), 1 deletion(-)
719b13
719b13
diff --git a/migration/migration.c b/migration/migration.c
719b13
index c8aa55d2fe..87b4a6c3f9 100644
719b13
--- a/migration/migration.c
719b13
+++ b/migration/migration.c
719b13
@@ -1010,6 +1010,9 @@ static void populate_ram_info(MigrationInfo *info, MigrationState *s)
719b13
     info->ram->page_size = page_size;
719b13
     info->ram->multifd_bytes = ram_counters.multifd_bytes;
719b13
     info->ram->pages_per_second = s->pages_per_second;
719b13
+    info->ram->precopy_bytes = ram_counters.precopy_bytes;
719b13
+    info->ram->downtime_bytes = ram_counters.downtime_bytes;
719b13
+    info->ram->postcopy_bytes = ram_counters.postcopy_bytes;
719b13
 
719b13
     if (migrate_use_xbzrle()) {
719b13
         info->has_xbzrle_cache = true;
719b13
diff --git a/migration/ram.c b/migration/ram.c
719b13
index 3e82c4ff46..e7173da217 100644
719b13
--- a/migration/ram.c
719b13
+++ b/migration/ram.c
719b13
@@ -393,6 +393,13 @@ MigrationStats ram_counters;
719b13
 
719b13
 static void ram_transferred_add(uint64_t bytes)
719b13
 {
719b13
+    if (runstate_is_running()) {
719b13
+        ram_counters.precopy_bytes += bytes;
719b13
+    } else if (migration_in_postcopy()) {
719b13
+        ram_counters.postcopy_bytes += bytes;
719b13
+    } else {
719b13
+        ram_counters.downtime_bytes += bytes;
719b13
+    }
719b13
     ram_counters.transferred += bytes;
719b13
 }
719b13
 
719b13
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
719b13
index 2669156b28..8c384dc1b2 100644
719b13
--- a/monitor/hmp-cmds.c
719b13
+++ b/monitor/hmp-cmds.c
719b13
@@ -293,6 +293,18 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
719b13
             monitor_printf(mon, "postcopy request count: %" PRIu64 "\n",
719b13
                            info->ram->postcopy_requests);
719b13
         }
719b13
+        if (info->ram->precopy_bytes) {
719b13
+            monitor_printf(mon, "precopy ram: %" PRIu64 " kbytes\n",
719b13
+                           info->ram->precopy_bytes >> 10);
719b13
+        }
719b13
+        if (info->ram->downtime_bytes) {
719b13
+            monitor_printf(mon, "downtime ram: %" PRIu64 " kbytes\n",
719b13
+                           info->ram->downtime_bytes >> 10);
719b13
+        }
719b13
+        if (info->ram->postcopy_bytes) {
719b13
+            monitor_printf(mon, "postcopy ram: %" PRIu64 " kbytes\n",
719b13
+                           info->ram->postcopy_bytes >> 10);
719b13
+        }
719b13
     }
719b13
 
719b13
     if (info->has_disk) {
719b13
diff --git a/qapi/migration.json b/qapi/migration.json
719b13
index fe70a0c4b2..c8ec260ab0 100644
719b13
--- a/qapi/migration.json
719b13
+++ b/qapi/migration.json
719b13
@@ -46,6 +46,15 @@
719b13
 # @pages-per-second: the number of memory pages transferred per second
719b13
 #                    (Since 4.0)
719b13
 #
719b13
+# @precopy-bytes: The number of bytes sent in the pre-copy phase
719b13
+#                 (since 7.0).
719b13
+#
719b13
+# @downtime-bytes: The number of bytes sent while the guest is paused
719b13
+#                  (since 7.0).
719b13
+#
719b13
+# @postcopy-bytes: The number of bytes sent during the post-copy phase
719b13
+#                  (since 7.0).
719b13
+#
719b13
 # Since: 0.14
719b13
 ##
719b13
 { 'struct': 'MigrationStats',
719b13
@@ -54,7 +63,9 @@
719b13
            'normal-bytes': 'int', 'dirty-pages-rate' : 'int',
719b13
            'mbps' : 'number', 'dirty-sync-count' : 'int',
719b13
            'postcopy-requests' : 'int', 'page-size' : 'int',
719b13
-           'multifd-bytes' : 'uint64', 'pages-per-second' : 'uint64' } }
719b13
+           'multifd-bytes' : 'uint64', 'pages-per-second' : 'uint64',
719b13
+           'precopy-bytes' : 'uint64', 'downtime-bytes' : 'uint64',
719b13
+           'postcopy-bytes' : 'uint64' } }
719b13
 
719b13
 ##
719b13
 # @XBZRLECacheStats:
719b13
-- 
719b13
2.35.3
719b13