From: Wei Wang <wei.w.wang@intel.com>
To: qemu-devel@nongnu.org, quintela@redhat.com, dgilbert@redhat.com,
peterx@redhat.com
Cc: gloryxiao@tencent.com, kevin.tian@intel.com,
wei.w.wang@intel.com, yi.y.sun@intel.com
Subject: [PATCH v1 1/2] migration/xbzrle: replace transferred xbzrle bytes with encoded bytes
Date: Mon, 20 Apr 2020 11:06:42 +0800 [thread overview]
Message-ID: <1587352003-3312-2-git-send-email-wei.w.wang@intel.com> (raw)
In-Reply-To: <1587352003-3312-1-git-send-email-wei.w.wang@intel.com>
Like compressed_size which indicates how many bytes are compressed, we
need encoded_size to understand how many bytes are encoded with xbzrle
during migration.
Replace the old xbzrle_counter.bytes, instead of adding a new counter,
because we don't find a usage of xbzrle_counter.bytes currently, which
includes 3 more bytes of the migration transfer protocol header (in
addition to the encoding header). The encoded_size will further be used
to calculate the encoding rate.
Signed-off-by: Yi Sun <yi.y.sun@intel.com>
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
---
migration/migration.c | 2 +-
migration/ram.c | 18 +++++++++---------
monitor/hmp-cmds.c | 4 ++--
qapi/migration.json | 6 +++---
4 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index 187ac0410c..8e7ee0d76b 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -926,7 +926,7 @@ static void populate_ram_info(MigrationInfo *info, MigrationState *s)
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->bytes = xbzrle_counters.bytes;
+ info->xbzrle_cache->encoded_size = xbzrle_counters.encoded_size;
info->xbzrle_cache->pages = xbzrle_counters.pages;
info->xbzrle_cache->cache_miss = xbzrle_counters.cache_miss;
info->xbzrle_cache->cache_miss_rate = xbzrle_counters.cache_miss_rate;
diff --git a/migration/ram.c b/migration/ram.c
index 04f13feb2e..bca5878f25 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -677,7 +677,7 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data,
ram_addr_t current_addr, RAMBlock *block,
ram_addr_t offset, bool last_stage)
{
- int encoded_len = 0, bytes_xbzrle;
+ int encoded_size = 0, bytes_xbzrle;
uint8_t *prev_cached_page;
if (!cache_is_cached(XBZRLE.cache, current_addr,
@@ -702,7 +702,7 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data,
memcpy(XBZRLE.current_buf, *current_data, TARGET_PAGE_SIZE);
/* XBZRLE encoding (if there is no overflow) */
- encoded_len = xbzrle_encode_buffer(prev_cached_page, XBZRLE.current_buf,
+ encoded_size = xbzrle_encode_buffer(prev_cached_page, XBZRLE.current_buf,
TARGET_PAGE_SIZE, XBZRLE.encoded_buf,
TARGET_PAGE_SIZE);
@@ -710,7 +710,7 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data,
* Update the cache contents, so that it corresponds to the data
* sent, in all cases except where we skip the page.
*/
- if (!last_stage && encoded_len != 0) {
+ if (!last_stage && encoded_size != 0) {
memcpy(prev_cached_page, XBZRLE.current_buf, TARGET_PAGE_SIZE);
/*
* In the case where we couldn't compress, ensure that the caller
@@ -720,10 +720,10 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data,
*current_data = prev_cached_page;
}
- if (encoded_len == 0) {
+ if (encoded_size == 0) {
trace_save_xbzrle_page_skipping();
return 0;
- } else if (encoded_len == -1) {
+ } else if (encoded_size == -1) {
trace_save_xbzrle_page_overflow();
xbzrle_counters.overflow++;
return -1;
@@ -733,11 +733,11 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data,
bytes_xbzrle = save_page_header(rs, rs->f, block,
offset | RAM_SAVE_FLAG_XBZRLE);
qemu_put_byte(rs->f, ENCODING_FLAG_XBZRLE);
- qemu_put_be16(rs->f, encoded_len);
- qemu_put_buffer(rs->f, XBZRLE.encoded_buf, encoded_len);
- bytes_xbzrle += encoded_len + 1 + 2;
+ qemu_put_be16(rs->f, encoded_size);
+ qemu_put_buffer(rs->f, XBZRLE.encoded_buf, encoded_size);
+ bytes_xbzrle += encoded_size + 1 + 2;
xbzrle_counters.pages++;
- xbzrle_counters.bytes += bytes_xbzrle;
+ xbzrle_counters.encoded_size += encoded_size;
ram_counters.transferred += bytes_xbzrle;
return 1;
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 9b94e67879..6d3b35ca64 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -295,8 +295,8 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
if (info->has_xbzrle_cache) {
monitor_printf(mon, "cache size: %" PRIu64 " bytes\n",
info->xbzrle_cache->cache_size);
- monitor_printf(mon, "xbzrle transferred: %" PRIu64 " kbytes\n",
- info->xbzrle_cache->bytes >> 10);
+ monitor_printf(mon, "xbzrle encoded size: %" PRIu64 " kbytes\n",
+ info->xbzrle_cache->encoded_size >> 10);
monitor_printf(mon, "xbzrle pages: %" PRIu64 " pages\n",
info->xbzrle_cache->pages);
monitor_printf(mon, "xbzrle cache miss: %" PRIu64 "\n",
diff --git a/qapi/migration.json b/qapi/migration.json
index eca2981d0a..bf195ff6ac 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -62,7 +62,7 @@
#
# @cache-size: XBZRLE cache size
#
-# @bytes: amount of bytes already transferred to the target VM
+# @encoded_size: amount of bytes encoded
#
# @pages: amount of pages transferred to the target VM
#
@@ -75,7 +75,7 @@
# Since: 1.2
##
{ 'struct': 'XBZRLECacheStats',
- 'data': {'cache-size': 'int', 'bytes': 'int', 'pages': 'int',
+ 'data': {'cache-size': 'int', 'encoded_size': 'int', 'pages': 'int',
'cache-miss': 'int', 'cache-miss-rate': 'number',
'overflow': 'int' } }
@@ -333,7 +333,7 @@
# },
# "xbzrle-cache":{
# "cache-size":67108864,
-# "bytes":20971520,
+# "encoded_size":20971520,
# "pages":2444343,
# "cache-miss":2244,
# "cache-miss-rate":0.123,
--
2.20.1
next prev parent reply other threads:[~2020-04-20 4:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-20 3:06 [PATCH v1 0/2] Migration xbzrle changes Wei Wang
2020-04-20 3:06 ` Wei Wang [this message]
2020-04-20 9:29 ` [PATCH v1 1/2] migration/xbzrle: replace transferred xbzrle bytes with encoded bytes Daniel P. Berrangé
2020-04-20 9:49 ` Wei Wang
2020-04-21 19:21 ` Dr. David Alan Gilbert
2020-04-22 2:51 ` Wei Wang
2020-04-24 10:47 ` Dr. David Alan Gilbert
2020-04-27 7:26 ` Wei Wang
2020-04-20 3:06 ` [PATCH v1 2/2] migration/xbzrle: add encoding rate Wei Wang
2020-04-20 9:30 ` Daniel P. Berrangé
2020-04-20 14:53 ` Eric Blake
2020-04-21 1:14 ` Wei Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1587352003-3312-2-git-send-email-wei.w.wang@intel.com \
--to=wei.w.wang@intel.com \
--cc=dgilbert@redhat.com \
--cc=gloryxiao@tencent.com \
--cc=kevin.tian@intel.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=yi.y.sun@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).