From patchwork Fri Jan 11 06:37:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 1023409 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TAAONjqC"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43bYBC0f8Dz9sCh for ; Fri, 11 Jan 2019 17:39:31 +1100 (AEDT) Received: from localhost ([127.0.0.1]:54503 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghqTZ-0003GC-2b for incoming@patchwork.ozlabs.org; Fri, 11 Jan 2019 01:39:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghqS2-0002Zt-GB for qemu-devel@nongnu.org; Fri, 11 Jan 2019 01:37:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghqS1-0007YM-ED for qemu-devel@nongnu.org; Fri, 11 Jan 2019 01:37:54 -0500 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:36699) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ghqS1-0007V4-7S for qemu-devel@nongnu.org; Fri, 11 Jan 2019 01:37:53 -0500 Received: by mail-pf1-x42a.google.com with SMTP id b85so6501256pfc.3 for ; Thu, 10 Jan 2019 22:37:53 -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=LmgMEMti+z/l1IMU5qcc3+pH5l7mn1xGFRW4iyILREA=; b=TAAONjqCOLuD0+E5Ao/svOsR2IBEs3yUgnoersZhXQZU8zvfbFDSzFqoYKHfD2AC0n hi2ciNegrOlsq4Mtgta0Yyfs54mYFR9gTUgdYU0yPwIeOZCEkMPdJalISioUJrCxVp3t kOA9mLhiSNsHFaZMKpRnKOXofrnUsy4/9iW924VrNCe15nHxyJ6z3O3vWhiUrDThNJ8f mCYEZtj5xaGiYYC8Fx/pPwHfXpCn7YUMylv++LBQjZpZJVc8zz2hS6mH0ITZ58IRgh9q iBHT4I6JK1gGljfuvUkuh8ZVqdx/L8yGnoGLVGxYC5Z9DT2sm0J9fwTtVHV7nOI+OIDg nggg== 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=LmgMEMti+z/l1IMU5qcc3+pH5l7mn1xGFRW4iyILREA=; b=Kqq/44lA0tRQEz0IBxu0Hj1i++FJ0FMlZSa7BaQp8zTrZe4TT4XcNNjrSPwP9wtfdh 6DKK4qL5lkgEoYiNycOHtaWHrXeNx846riUg+Vl+fDjFeIyW9aj3lbo7ltVevnRc+hZd cZxefxN2Y3+e0J0xBm/8vs539vD5Tw/xNDLrqem+8O8E7AnPYAeYwcsC09efm9Xo0tAv 8ytEH/XZ1msfPXsns7jOtZrjzEF04TM8d27tFdJQIqHGNEIFeA6xr6iVHtkAXt98UU/B rHY+npTN5u/Lfq0CddRwops0zg7TmjhPuJiPhoWiRAUKQO9jG2ioAhEPLzL0EABgg5i3 EAFg== X-Gm-Message-State: AJcUukdylxdRlq9YDonmFAkG3q1OL2f/9Yrk5KuclxTZ6fz2SNgIKF4V WimROYYXPX6s05t0sqC9hHI= X-Google-Smtp-Source: ALg8bN4J4MYJLbz8KUzD94oX1guKoUicQny9e6bYQWAnF6u7SF4/WqF8Oqsmo73CZRWHqiNXGP2iyQ== X-Received: by 2002:a63:de04:: with SMTP id f4mr9934252pgg.292.1547188672170; Thu, 10 Jan 2019 22:37:52 -0800 (PST) Received: from localhost.localdomain ([203.205.141.36]) by smtp.gmail.com with ESMTPSA id 78sm141460933pft.184.2019.01.10.22.37.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Jan 2019 22:37:51 -0800 (PST) From: guangrong.xiao@gmail.com X-Google-Original-From: xiaoguangrong@tencent.com To: pbonzini@redhat.com, mst@redhat.com, mtosatti@redhat.com Date: Fri, 11 Jan 2019 14:37:30 +0800 Message-Id: <20190111063732.10484-2-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20190111063732.10484-1-xiaoguangrong@tencent.com> References: <20190111063732.10484-1-xiaoguangrong@tencent.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::42a Subject: [Qemu-devel] [PATCH v2 1/3] migration: introduce pages-per-second X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, quintela@redhat.com, Xiao Guangrong , qemu-devel@nongnu.org, peterx@redhat.com, dgilbert@redhat.com, wei.w.wang@intel.com, cota@braap.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 is the one we want Signed-off-by: Xiao Guangrong Reviewed-by: Dr. David Alan Gilbert --- hmp.c | 2 ++ migration/migration.c | 11 ++++++++++- migration/migration.h | 8 ++++++++ migration/ram.c | 6 ++++++ qapi/migration.json | 5 ++++- 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/hmp.c b/hmp.c index 80aa5ab504..944e3e072d 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 ffc4d9e556..a82d594f29 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -777,6 +777,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; @@ -1563,6 +1564,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; @@ -2881,7 +2883,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; @@ -2898,6 +2900,11 @@ 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)); + /* * if we haven't sent anything, we don't want to * recalculate. 10000 is a small enough number for our purposes @@ -2910,6 +2917,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); @@ -3314,6 +3322,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 e413d4d8b6..810effc384 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 */ @@ -271,6 +277,8 @@ bool migrate_use_block_incremental(void); int migrate_max_cpu_throttle(void); bool migrate_use_return_path(void); +uint64_t ram_get_total_transferred_pages(void); + bool migrate_use_compression(void); int migrate_compress_level(void); int migrate_compress_threads(void); diff --git a/migration/ram.c b/migration/ram.c index 7e7deec4d8..7e429b0502 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1593,6 +1593,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 migration_update_rates(RAMState *rs, int64_t end_time) { uint64_t page_count = rs->target_page_count - rs->target_page_count_prev; diff --git a/qapi/migration.json b/qapi/migration.json index 31b589ec26..c5babd03b0 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: