[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 10/11] Add XBZRLE statistics
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 10/11] Add XBZRLE statistics |
Date: |
Tue, 24 Jul 2012 20:19:23 +0200 |
From: Orit Wasserman <address@hidden>
Signed-off-by: Benoit Hudzia <address@hidden>
Signed-off-by: Petter Svard <address@hidden>
Signed-off-by: Aidan Shribman <address@hidden>
Signed-off-by: Orit Wasserman <address@hidden>
Signed-off-by: Juan Quintela <address@hidden>
---
arch_init.c | 28 ++++++++++++++++++++++++++++
hmp.c | 21 +++++++++++++++++++++
migration.c | 36 +++++++++++++++++++++++++++++-------
migration.h | 4 ++++
qapi-schema.json | 27 +++++++++++++++++++++++++--
qmp-commands.hx | 33 ++++++++++++++++++++++++++++++++-
6 files changed, 139 insertions(+), 10 deletions(-)
diff --git a/arch_init.c b/arch_init.c
index 12afc46..f89908f 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -209,7 +209,11 @@ int64_t xbzrle_cache_resize(int64_t new_size)
typedef struct AccountingInfo {
uint64_t dup_pages;
uint64_t norm_pages;
+ uint64_t xbzrle_bytes;
+ uint64_t xbzrle_pages;
+ uint64_t xbzrle_cache_miss;
uint64_t iterations;
+ uint64_t xbzrle_overflows;
} AccountingInfo;
static AccountingInfo acct_info;
@@ -239,6 +243,26 @@ uint64_t norm_mig_pages_transferred(void)
return acct_info.norm_pages;
}
+uint64_t xbzrle_mig_bytes_transferred(void)
+{
+ return acct_info.xbzrle_bytes;
+}
+
+uint64_t xbzrle_mig_pages_transferred(void)
+{
+ return acct_info.xbzrle_pages;
+}
+
+uint64_t xbzrle_mig_pages_cache_miss(void)
+{
+ return acct_info.xbzrle_cache_miss;
+}
+
+uint64_t xbzrle_mig_pages_overflow(void)
+{
+ return acct_info.xbzrle_overflows;
+}
+
static void save_block_hdr(QEMUFile *f, RAMBlock *block, ram_addr_t offset,
int cont, int flag)
{
@@ -267,6 +291,7 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t
*current_data,
if (!cache_is_cached(XBZRLE.cache, current_addr)) {
cache_insert(XBZRLE.cache, current_addr,
g_memdup(current_data, TARGET_PAGE_SIZE));
+ acct_info.xbzrle_cache_miss++;
return -1;
}
@@ -284,6 +309,7 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t
*current_data,
return 0;
} else if (encoded_len == -1) {
DPRINTF("Overflow\n");
+ acct_info.xbzrle_overflows++;
/* update data in the cache */
memcpy(prev_cached_page, current_data, TARGET_PAGE_SIZE);
return -1;
@@ -301,7 +327,9 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t
*current_data,
qemu_put_byte(f, hdr.xh_flags);
qemu_put_be16(f, hdr.xh_len);
qemu_put_buffer(f, XBZRLE.encoded_buf, encoded_len);
+ acct_info.xbzrle_pages++;
bytes_sent = encoded_len + sizeof(hdr);
+ acct_info.xbzrle_bytes += bytes_sent;
return bytes_sent;
}
diff --git a/hmp.c b/hmp.c
index e0f520d..c141f90 100644
--- a/hmp.c
+++ b/hmp.c
@@ -168,6 +168,27 @@ void hmp_info_migrate(Monitor *mon)
info->disk->total >> 10);
}
+ if (info->has_xbzrle_cache) {
+ monitor_printf(mon, "cache size: %" PRIu64 " bytes\n",
+ info->xbzrle_cache->cache_size);
+ if (info->xbzrle_cache->has_xbzrle_bytes) {
+ monitor_printf(mon, "xbzrle transferred: %" PRIu64 " kbytes\n",
+ info->xbzrle_cache->xbzrle_bytes >> 10);
+ }
+ if (info->xbzrle_cache->has_xbzrle_pages) {
+ monitor_printf(mon, "xbzrle pages: %" PRIu64 " pages\n",
+ info->xbzrle_cache->xbzrle_pages);
+ }
+ if (info->xbzrle_cache->has_xbzrle_cache_miss) {
+ monitor_printf(mon, "xbzrle cache miss: %" PRIu64 "\n",
+ info->xbzrle_cache->xbzrle_cache_miss);
+ }
+ if (info->xbzrle_cache->has_xbzrle_overflow) {
+ monitor_printf(mon, "xbzrle overflow : %" PRIu64 "\n",
+ info->xbzrle_cache->xbzrle_overflow);
+ }
+ }
+
qapi_free_MigrationInfo(info);
}
diff --git a/migration.c b/migration.c
index cae444c..4be047a 100644
--- a/migration.c
+++ b/migration.c
@@ -133,6 +133,24 @@ static void get_capabilities(MigrationState *s,
MigrationInfo *info)
info->capabilities->next = NULL;
}
}
+
+static void get_xbzrle_cache_stats(MigrationInfo *info)
+{
+ if (migrate_use_xbzrle()) {
+ info->has_xbzrle_cache = true;
+ info->xbzrle_cache = g_malloc0(sizeof(*info->xbzrle_cache));
+ info->xbzrle_cache->cache_size = migrate_xbzrle_cache_size();
+ info->xbzrle_cache->has_xbzrle_bytes = true;
+ info->xbzrle_cache->xbzrle_bytes = xbzrle_mig_bytes_transferred();
+ info->xbzrle_cache->has_xbzrle_pages = true;
+ info->xbzrle_cache->xbzrle_pages = xbzrle_mig_pages_transferred();
+ info->xbzrle_cache->has_xbzrle_cache_miss = true;
+ info->xbzrle_cache->xbzrle_cache_miss = xbzrle_mig_pages_cache_miss();
+ info->xbzrle_cache->has_xbzrle_overflow = true;
+ info->xbzrle_cache->xbzrle_overflow = xbzrle_mig_pages_overflow();
+ }
+}
+
MigrationInfo *qmp_query_migrate(Error **errp)
{
MigrationInfo *info = g_malloc0(sizeof(*info));
@@ -142,6 +160,14 @@ MigrationInfo *qmp_query_migrate(Error **errp)
case MIG_STATE_SETUP:
/* no migration has ever happened; show enabled capabilities */
get_capabilities(s, info);
+
+ /* display xbzrle cache size */
+ if (migrate_use_xbzrle()) {
+ info->has_xbzrle_cache = true;
+ info->xbzrle_cache = g_malloc0(sizeof(*info->xbzrle_cache));
+ info->xbzrle_cache->cache_size = migrate_xbzrle_cache_size();
+ }
+
break;
case MIG_STATE_ACTIVE:
get_capabilities(s, info);
@@ -166,17 +192,13 @@ MigrationInfo *qmp_query_migrate(Error **errp)
info->disk->remaining = blk_mig_bytes_remaining();
info->disk->total = blk_mig_bytes_total();
}
+
+ get_xbzrle_cache_stats(info);
break;
case MIG_STATE_COMPLETED:
get_capabilities(s, info);
- info->has_ram = true;
- info->ram = g_malloc0(sizeof(*info->ram));
- info->ram->transferred = ram_bytes_transferred();
- info->ram->remaining = ram_bytes_remaining();
- info->ram->total = ram_bytes_total();
- info->ram->duplicate = dup_mig_pages_transferred();
- info->ram->normal = norm_mig_pages_transferred();
+ get_xbzrle_cache_stats(info);
info->has_status = true;
info->status = g_strdup("completed");
diff --git a/migration.h b/migration.h
index e4a7cd7..a9852fc 100644
--- a/migration.h
+++ b/migration.h
@@ -91,6 +91,10 @@ uint64_t dup_mig_bytes_transferred(void);
uint64_t dup_mig_pages_transferred(void);
uint64_t norm_mig_bytes_transferred(void);
uint64_t norm_mig_pages_transferred(void);
+uint64_t xbzrle_mig_bytes_transferred(void);
+uint64_t xbzrle_mig_pages_transferred(void);
+uint64_t xbzrle_mig_pages_overflow(void);
+uint64_t xbzrle_mig_pages_cache_miss(void);
/**
* @migrate_add_blocker - prevent migration from proceeding
diff --git a/qapi-schema.json b/qapi-schema.json
index 8676c1d..a4528f9 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -273,6 +273,26 @@
{ 'type': 'MigrationStats',
'data': {'transferred': 'int', 'remaining': 'int', 'total': 'int' ,
'total_time': 'int', '*duplicate': 'int', '*normal': 'int' } }
+##
+# @XBZRLECacheStats
+#
+# Detailed XBZRLE migration cache statistics
+#
+# @cache_size: XBZRLE cache size
+#
+# @xbzrle_bytes: amount of bytes already transferred to the target VM
+#
+# @xbzrle_pages: amount of pages transferred to the target VM
+#
+# @xbzrle_cache_miss: number of cache miss
+#
+# @xbzrle_overflow: number of overflows
+#
+# Since: 1.2
+##
+{ 'type': 'XBZRLECacheStats',
+ 'data': {'cache-size': 'int', '*xbzrle-bytes': 'int', '*xbzrle-pages': 'int',
+ '*xbzrle-cache-miss': 'int', '*xbzrle-overflow': 'int' } }
##
# @MigrationInfo
@@ -295,13 +315,16 @@
# @capabilities: #optional a list describing all the migration capabilities
# state (since 1.2)
#
+# @xbzrle-cache: #optional @XBZRLECacheStats containing detailed XBZRLE
+# migration statistics (since 1.2)
+#
# Since: 0.14.0
##
{ 'type': 'MigrationInfo',
'data': {'*status': 'str', '*ram': 'MigrationStats',
'*disk': 'MigrationStats',
- '*capabilities': ['MigrationCapabilityStatus']} }
-
+ '*capabilities': ['MigrationCapabilityStatus'],
+ '*xbzrle-cache': 'XBZRLECacheStats'} }
##
# @query-migrate
#
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 9a4bff0..3518e64 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2108,10 +2108,17 @@ The main json-object contains the following:
- "total": total (json-int)
- "capabilities": migration capabilities state
- "xbzrle" : XBZRLE state (json-bool)
+- "cache": only present if "status" and XBZRLE is active.
+ It is a json-object with the following XBZRLE information:
+ - "cache-size": XBZRLE cache size
+ - "xbzrle-bytes": total XBZRLE bytes transferred
+ - "xbzrle-pages": number of XBZRLE compressed pages
+ - "cache-miss": number of cache misses
+ - "overflow": number of XBZRLE overflows
+
Examples:
1. Before the first migration
-
-> { "execute": "query-migrate" }
<- { "return": {
"capabilities" : [ { "capability" : "xbzrle", "state" : false } ]
@@ -2172,6 +2179,30 @@ Examples:
}
}
+6. Migration is being performed and XBZRLE is active:
+
+-> { "execute": "query-migrate" }
+<- {
+ "return":{
+ "status":"active",
+ "capabilities" : [ { "capability": "xbzrle", "state" : true } ],
+ "ram":{
+ "total":1057024,
+ "remaining":1053304,
+ "transferred":3720,
+ "duplicate": 10,
+ "normal" : 3333
+ },
+ "cache":{
+ "cache-size": 1024
+ "xbzrle-transferred":20971520,
+ "xbzrle-pages":2444343,
+ "xbzrle-cache-miss":2244,
+ "xbzrle-overflow":34434
+ }
+ }
+ }
+
EQMP
{
--
1.7.10.4
- [Qemu-devel] [PATCH 01/11] Add migration capabilities, (continued)
- [Qemu-devel] [PATCH 01/11] Add migration capabilities, Juan Quintela, 2012/07/24
- [Qemu-devel] [PATCH 02/11] Add migrate_set_parameter command, Juan Quintela, 2012/07/24
- [Qemu-devel] [PATCH 03/11] Add XBZRLE documentation, Juan Quintela, 2012/07/24
- [Qemu-devel] [PATCH 06/11] Add xbzrle_encode_buffer and xbzrle_decode_buffer functions, Juan Quintela, 2012/07/24
- [Qemu-devel] [PATCH 05/11] Add uleb encoding/decoding functions, Juan Quintela, 2012/07/24
- [Qemu-devel] [PATCH 04/11] Add cache handling functions, Juan Quintela, 2012/07/24
- [Qemu-devel] [PATCH 07/11] Add XBZRLE to ram_save_block and ram_save_live, Juan Quintela, 2012/07/24
- [Qemu-devel] [PATCH 08/11] Add migrate_set_cachesize command, Juan Quintela, 2012/07/24
- [Qemu-devel] [PATCH 11/11] Restart optimization on stage3 update version, Juan Quintela, 2012/07/24
- [Qemu-devel] [PATCH 09/11] Add migration accounting for normal and duplicate pages, Juan Quintela, 2012/07/24
- [Qemu-devel] [PATCH 10/11] Add XBZRLE statistics,
Juan Quintela <=