From patchwork Thu Dec 13 07:57:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 10728127 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BABC915A6 for ; Thu, 13 Dec 2018 07:57:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACDF529DDD for ; Thu, 13 Dec 2018 07:57:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0C5329E4D; Thu, 13 Dec 2018 07:57:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9877E29DDD for ; Thu, 13 Dec 2018 07:57:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727194AbeLMH5q (ORCPT ); Thu, 13 Dec 2018 02:57:46 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:40841 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727159AbeLMH5q (ORCPT ); Thu, 13 Dec 2018 02:57:46 -0500 Received: by mail-pl1-f193.google.com with SMTP id u18so667722plq.7 for ; Wed, 12 Dec 2018 23:57:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6+EnqtRvCoharoM97Q1SEoFa2ichC+KYWbtjfSpbnkM=; b=OopCG6fG8PiyUNws75dBLSOBTfR/0NUatimRF7xvG09p6BOhOdzhJ9S2RHTj2JkhFq MMvTpYRIwavco0SFqfpoMOzjaIehs32hx1Mtd1sNZQInc/c4Bwj3BhMMrOg7byYBkxqw jGaPQMA4xnh7cuBcyTDN1d5dqxzDxIGbJHG199cxaZzwGwvyqy2ewW1Fj6Wh0xhgQ5lO D4UnzKzx26CztdBihtzvxD25Fl/DwoU3Kf/JCRC08DsyyVvSuMbU463RPB2iyiE3Nsqu JqJ6CRshNyGGBPju8YUON2CgTr0M328yNHJCPJsFA019KEY6bsqfoUO6jTYG6E6748S0 LB1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6+EnqtRvCoharoM97Q1SEoFa2ichC+KYWbtjfSpbnkM=; b=GzmlItiKr1bRCf1h7M8pmICBv0iBMJRz5zrjQxKw+gBHsfvkzXqGI2sQZSn0ezvGmQ MysUEuha0vGwejKnEISm44gr31o4qvjm/qDXpyANqVD4zMCI6povK8J+GajsAmMc+38t 4z8wTSt0joGtNEtMyMaJie8DeE9InMBIgauDvtMnntOTo1bhNe5bXNWMpO4ZAXRTVS16 tSkTLgez4Sn4qdleM8L/wmd/uu/+ETeqwgdAl3+obwHCChcXUKdjg35gjAZM5obg+KCC m6yDkkP2aMyU/QhxgJEMm/5x/o7PU7K6y/s18NuGi/pf0Pj/1/a9KwIvaI1t92bt3nNG BS3g== X-Gm-Message-State: AA+aEWZrk/j85eo1a/PGtm8KdBFi6vedZA1IhOcZu67UVZi82JabpylD yPJPdIB2p8FnaRRrYYYmcgA= X-Google-Smtp-Source: AFSGD/XymLCnOtA3wLVcHcaszlaVS2kNdi0hLpHjaoqs3EUmeIOFZwuG2xfRme/K19tivGlDgNaL/w== X-Received: by 2002:a17:902:50e:: with SMTP id 14mr22462375plf.141.1544687864553; Wed, 12 Dec 2018 23:57:44 -0800 (PST) Received: from localhost.localdomain ([203.205.141.36]) by smtp.gmail.com with ESMTPSA id h19sm1423618pfn.114.2018.12.12.23.57.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Dec 2018 23:57:44 -0800 (PST) From: guangrong.xiao@gmail.com X-Google-Original-From: xiaoguangrong@tencent.com To: pbonzini@redhat.com, mst@redhat.com, mtosatti@redhat.com Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, dgilbert@redhat.com, peterx@redhat.com, wei.w.wang@intel.com, eblake@redhat.com, quintela@redhat.com, cota@braap.org, Xiao Guangrong Subject: [PATCH 2/2] migration: introduce pages-per-second Date: Thu, 13 Dec 2018 15:57:27 +0800 Message-Id: <20181213075727.23540-3-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20181213075727.23540-1-xiaoguangrong@tencent.com> References: <20181213075727.23540-1-xiaoguangrong@tencent.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Xiao Guangrong It introduces a new statistic, pages-per-second, as bandwidth or mbps is not enough to measure the performance of posting pages out as we have compression, xbzrle, which can significantly reduce the amount of the data size, instead, pages-per-second if the one we want Signed-off-by: Xiao Guangrong --- hmp.c | 2 ++ migration/migration.c | 12 +++++++++++- migration/migration.h | 8 ++++++++ migration/ram.c | 6 ++++++ qapi/migration.json | 5 ++++- 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/hmp.c b/hmp.c index 2c5bb504d4..bd7e30cc2e 100644 --- a/hmp.c +++ b/hmp.c @@ -236,6 +236,8 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) info->ram->page_size >> 10); monitor_printf(mon, "multifd bytes: %" PRIu64 " kbytes\n", info->ram->multifd_bytes >> 10); + monitor_printf(mon, "pages-per-second: %" PRIu64 "\n", + info->ram->pages_per_second); if (info->ram->dirty_pages_rate) { monitor_printf(mon, "dirty pages rate: %" PRIu64 " pages\n", diff --git a/migration/migration.c b/migration/migration.c index d19935b529..2a54cd3423 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -780,6 +780,7 @@ static void populate_ram_info(MigrationInfo *info, MigrationState *s) info->ram->postcopy_requests = ram_counters.postcopy_requests; info->ram->page_size = qemu_target_page_size(); info->ram->multifd_bytes = ram_counters.multifd_bytes; + info->ram->pages_per_second = s->pages_per_second; if (migrate_use_xbzrle()) { info->has_xbzrle_cache = true; @@ -1578,6 +1579,7 @@ void migrate_init(MigrationState *s) s->rp_state.from_dst_file = NULL; s->rp_state.error = false; s->mbps = 0.0; + s->pages_per_second = 0.0; s->downtime = 0; s->expected_downtime = 0; s->setup_time = 0; @@ -2914,7 +2916,7 @@ static void migration_calculate_complete(MigrationState *s) static void migration_update_counters(MigrationState *s, int64_t current_time) { - uint64_t transferred, time_spent; + uint64_t transferred, transferred_pages, time_spent; uint64_t current_bytes; /* bytes transferred since the beginning */ double bandwidth; @@ -2931,6 +2933,12 @@ static void migration_update_counters(MigrationState *s, s->mbps = (((double) transferred * 8.0) / ((double) time_spent / 1000.0)) / 1000.0 / 1000.0; + + transferred_pages = ram_get_total_transferred_pages() - + s->iteration_initial_pages; + s->pages_per_second = (double) transferred_pages / + (((double) time_spent / 1000.0)); + compress_adaptive_update(s->mbps); /* @@ -2945,6 +2953,7 @@ static void migration_update_counters(MigrationState *s, s->iteration_start_time = current_time; s->iteration_initial_bytes = current_bytes; + s->iteration_initial_pages = ram_get_total_transferred_pages(); trace_migrate_transferred(transferred, time_spent, bandwidth, s->threshold_size); @@ -3351,6 +3360,7 @@ static void migration_instance_init(Object *obj) ms->state = MIGRATION_STATUS_NONE; ms->mbps = -1; + ms->pages_per_second = -1; qemu_sem_init(&ms->pause_sem, 0); qemu_mutex_init(&ms->error_mutex); diff --git a/migration/migration.h b/migration/migration.h index d631776230..73a6803cc4 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -126,6 +126,12 @@ struct MigrationState */ QemuSemaphore rate_limit_sem; + /* pages already send at the beggining of current interation */ + uint64_t iteration_initial_pages; + + /* pages transferred per second */ + double pages_per_second; + /* bytes already send at the beggining of current interation */ uint64_t iteration_initial_bytes; /* time at the start of current iteration */ @@ -279,6 +285,8 @@ int migrate_compress_wait_thread(void); int migrate_compress_wait_thread_adaptive(void); void compress_adaptive_update(double mbps); +uint64_t ram_get_total_transferred_pages(void); + int migrate_decompress_threads(void); bool migrate_use_events(void); bool migrate_postcopy_blocktime(void); diff --git a/migration/ram.c b/migration/ram.c index 3b08a605e4..b6b08a4800 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1613,6 +1613,12 @@ uint64_t ram_pagesize_summary(void) return summary; } +uint64_t ram_get_total_transferred_pages(void) +{ + return ram_counters.normal + ram_counters.duplicate + + compression_counters.pages + xbzrle_counters.pages; +} + static void compress_adaptive_init(void) { /* fully wait on default. */ diff --git a/qapi/migration.json b/qapi/migration.json index 6d925c73fc..e64b2e3901 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -41,6 +41,9 @@ # # @multifd-bytes: The number of bytes sent through multifd (since 3.0) # +# @pages-per-second: the number of memory pages transferred per second +# (Since 3.2) +# # Since: 0.14.0 ## { 'struct': 'MigrationStats', @@ -49,7 +52,7 @@ 'normal-bytes': 'int', 'dirty-pages-rate' : 'int', 'mbps' : 'number', 'dirty-sync-count' : 'int', 'postcopy-requests' : 'int', 'page-size' : 'int', - 'multifd-bytes' : 'uint64' } } + 'multifd-bytes' : 'uint64', 'pages-per-second' : 'uint64' } } ## # @XBZRLECacheStats: