From patchwork Wed Jul 25 14:50:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Orit Wasserman X-Patchwork-Id: 173205 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F3D8F2C00A9 for ; Thu, 26 Jul 2012 01:43:02 +1000 (EST) Received: from localhost ([::1]:42245 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Su2x5-00020C-NE for incoming@patchwork.ozlabs.org; Wed, 25 Jul 2012 10:52:39 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50210) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Su2wu-0001mt-S8 for qemu-devel@nongnu.org; Wed, 25 Jul 2012 10:52:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Su2wo-000396-QZ for qemu-devel@nongnu.org; Wed, 25 Jul 2012 10:52:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44746) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Su2wo-00038M-FY for qemu-devel@nongnu.org; Wed, 25 Jul 2012 10:52:22 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6PEpN5u012142 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 25 Jul 2012 10:51:23 -0400 Received: from dhcp-1-120.tlv.redhat.com (vpn-201-149.tlv.redhat.com [10.35.201.149]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q6PEoLQX024922; Wed, 25 Jul 2012 10:51:18 -0400 From: Orit Wasserman To: qemu-devel@nongnu.org Date: Wed, 25 Jul 2012 17:50:33 +0300 Message-Id: <1343227834-5400-12-git-send-email-owasserm@redhat.com> In-Reply-To: <1343227834-5400-1-git-send-email-owasserm@redhat.com> References: <1343227834-5400-1-git-send-email-owasserm@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, aliguori@us.ibm.com, quintela@redhat.com, Petter Svard , stefanha@gmail.com, mdroth@linux.vnet.ibm.com, Benoit Hudzia , lcapitulino@redhat.com, blauwirbel@gmail.com, Orit Wasserman , chegu_vinod@hp.com, avi@redhat.com, Aidan Shribman , pbonzini@redhat.com, eblake@redhat.com Subject: [Qemu-devel] [PATCH 10/11] Add XBZRLE statistics X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Benoit Hudzia Signed-off-by: Petter Svard Signed-off-by: Aidan Shribman Signed-off-by: Orit Wasserman Signed-off-by: Juan Quintela --- arch_init.c | 28 ++++++++++++++++++++++++++++ hmp.c | 21 +++++++++++++++++++++ migration.c | 28 ++++++++++++++++++++++++++++ migration.h | 4 ++++ qapi-schema.json | 26 +++++++++++++++++++++++++- qmp-commands.hx | 32 +++++++++++++++++++++++++++++++- 6 files changed, 137 insertions(+), 2 deletions(-) diff --git a/arch_init.c b/arch_init.c index e50cdf2..f484bd5 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 9770d7b..383d5b1 100644 --- a/hmp.c +++ b/hmp.c @@ -172,6 +172,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); qapi_free_MigrationParameters(params); } diff --git a/migration.c b/migration.c index 4dc99ba..fb802bc 100644 --- a/migration.c +++ b/migration.c @@ -136,6 +136,23 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) return params; } +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)); @@ -144,6 +161,13 @@ MigrationInfo *qmp_query_migrate(Error **errp) switch (s->state) { case MIG_STATE_SETUP: /* no migration has happened ever */ + + /* 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: info->has_status = true; @@ -166,8 +190,12 @@ 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_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 88b7b56..9418f23 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 @@ -292,11 +312,15 @@ # status, only returned if status is 'active' and it is a block # migration # +# @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'} } + '*disk': 'MigrationStats', + '*xbzrle-cache': 'XBZRLECacheStats'} } ## # @query-migrate diff --git a/qmp-commands.hx b/qmp-commands.hx index d0e8878..946d921 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -2106,10 +2106,16 @@ The main json-object contains the following: - "transferred": amount transferred (json-int) - "remaining": amount remaining (json-int) - "total": total (json-int) +- "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": {} } @@ -2164,6 +2170,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 {