From nobody Tue Feb 10 11:14:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676564441955288.5182624777734; Thu, 16 Feb 2023 08:20:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSgzG-0001vH-6d; Thu, 16 Feb 2023 11:19:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSgzE-0001kx-7e for qemu-devel@nongnu.org; Thu, 16 Feb 2023 11:19:56 -0500 Received: from prt-mail.chinatelecom.cn ([42.123.76.223] helo=chinatelecom.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSgz6-00057o-Ks for qemu-devel@nongnu.org; Thu, 16 Feb 2023 11:19:55 -0500 Received: from clientip-118.116.19.27 (unknown [172.18.0.188]) by chinatelecom.cn (HERMES) with SMTP id 1F51D2800E2; Fri, 17 Feb 2023 00:19:42 +0800 (CST) Received: from ([118.116.19.27]) by app0023 with ESMTP id 39ca26f00da34716880fb8ea48d74c5c for qemu-devel@nongnu.org; Fri, 17 Feb 2023 00:19:46 CST HMM_SOURCE_IP: 172.18.0.188:50698.1319324123 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP X-189-SAVE-TO-SEND: +huangy81@chinatelecom.cn X-Transaction-ID: 39ca26f00da34716880fb8ea48d74c5c X-Real-From: huangy81@chinatelecom.cn X-Receive-IP: 118.116.19.27 X-MEDUSA-Status: 0 From: huangy81@chinatelecom.cn To: qemu-devel Cc: Markus Armbruster , Peter Xu , "Dr. David Alan Gilbert" , Juan Quintela , Thomas Huth , Paolo Bonzini , Eric Blake , Peter Maydell , Richard Henderson , =?UTF-8?q?Hyman=20Huang=28=E9=BB=84=E5=8B=87=29?= Subject: [PATCH v4 09/10] migration: Extend query-migrate to provide dirty page limit info Date: Fri, 17 Feb 2023 00:18:38 +0800 Message-Id: <92b74c98dbb6df18cda73149088083d276a660a3.1676563222.git.huangy81@chinatelecom.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=42.123.76.223; envelope-from=huangy81@chinatelecom.cn; helo=chinatelecom.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1676564443077100001 From: Hyman Huang(=E9=BB=84=E5=8B=87) Extend query-migrate to provide throttle time and estimated ring full time with dirty-limit capability enabled, through which we can observe if dirty limit take effect during live migration. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) Signed-off-by: Markus Armbruster --- include/sysemu/dirtylimit.h | 2 ++ migration/migration-hmp-cmds.c | 10 +++++++++ migration/migration.c | 10 +++++++++ qapi/migration.json | 15 ++++++++++++- softmmu/dirtylimit.c | 39 ++++++++++++++++++++++++++++++++++ 5 files changed, 75 insertions(+), 1 deletion(-) diff --git a/include/sysemu/dirtylimit.h b/include/sysemu/dirtylimit.h index 8d2c1f3a6b..410a2bc0b6 100644 --- a/include/sysemu/dirtylimit.h +++ b/include/sysemu/dirtylimit.h @@ -34,4 +34,6 @@ void dirtylimit_set_vcpu(int cpu_index, void dirtylimit_set_all(uint64_t quota, bool enable); void dirtylimit_vcpu_execute(CPUState *cpu); +int64_t dirtylimit_throttle_time_per_round(void); +int64_t dirtylimit_ring_full_time(void); #endif diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index a61ec80d9d..1f090faec5 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -171,6 +171,16 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) info->cpu_throttle_percentage); } =20 + if (info->has_dirty_limit_throttle_time_per_round) { + monitor_printf(mon, "dirty-limit throttle time: %" PRIi64 " us\n", + info->dirty_limit_throttle_time_per_round); + } + + if (info->has_dirty_limit_ring_full_time) { + monitor_printf(mon, "dirty-limit ring full time: %" PRIi64 " us\n", + info->dirty_limit_ring_full_time); + } + if (info->has_postcopy_blocktime) { monitor_printf(mon, "postcopy blocktime: %u\n", info->postcopy_blocktime); diff --git a/migration/migration.c b/migration/migration.c index 7ccbc07257..1f1e1f2268 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -65,6 +65,7 @@ #include "sysemu/qtest.h" #include "ui/qemu-spice.h" #include "sysemu/kvm.h" +#include "sysemu/dirtylimit.h" =20 #define MAX_THROTTLE (128 << 20) /* Migration transfer speed throttl= ing */ =20 @@ -1203,6 +1204,15 @@ static void populate_ram_info(MigrationInfo *info, M= igrationState *s) info->ram->remaining =3D ram_bytes_remaining(); info->ram->dirty_pages_rate =3D ram_counters.dirty_pages_rate; } + + if (migrate_dirty_limit() && dirtylimit_in_service()) { + info->has_dirty_limit_throttle_time_per_round =3D true; + info->dirty_limit_throttle_time_per_round =3D + dirtylimit_throttle_time_per_round(); + + info->has_dirty_limit_ring_full_time =3D true; + info->dirty_limit_ring_full_time =3D dirtylimit_us_ring_full(); + } } =20 static void populate_disk_info(MigrationInfo *info) diff --git a/qapi/migration.json b/qapi/migration.json index b7a92be055..f511771101 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -242,6 +242,17 @@ # Present and non-empty when migration is blocked. # (since 6.0) # +# @dirty-limit-throttle-time-per-round: Maximum throttle time (in microsec= onds) of virtual +# CPUs each dirty ring full round, w= hich shows how +# MigrationCapability dirty-limit af= fects the guest +# during live migration. (since 8.0) +# +# @dirty-limit-ring-full-time: Estimated average dirty ring full time (in = microseconds) +# each dirty ring full round, note that the v= alue equals +# dirty ring memory size divided by average d= irty page rate +# of virtual CPU, which can be used to observ= e the average +# memory load of virtual CPU indirectly. (sin= ce 8.0) +# # Since: 0.14 ## { 'struct': 'MigrationInfo', @@ -259,7 +270,9 @@ '*postcopy-blocktime' : 'uint32', '*postcopy-vcpu-blocktime': ['uint32'], '*compression': 'CompressionStats', - '*socket-address': ['SocketAddress'] } } + '*socket-address': ['SocketAddress'], + '*dirty-limit-throttle-time-per-round': 'int64', + '*dirty-limit-ring-full-time': 'int64'} } =20 ## # @query-migrate: diff --git a/softmmu/dirtylimit.c b/softmmu/dirtylimit.c index ae77ebe5c5..3c07844a11 100644 --- a/softmmu/dirtylimit.c +++ b/softmmu/dirtylimit.c @@ -568,6 +568,45 @@ static struct DirtyLimitInfo *dirtylimit_query_vcpu(in= t cpu_index) return info; } =20 +/* Return the max throttle time of each virtual CPU */ +int64_t dirtylimit_throttle_time_per_round(void) +{ + CPUState *cpu; + int64_t max =3D 0; + + CPU_FOREACH(cpu) { + if (cpu->throttle_us_per_full > max) { + max =3D cpu->throttle_us_per_full; + } + } + + return max; +} + +/* + * Estimate average dirty ring full time of each virtaul CPU. + * Return -1 if guest doesn't dirty memory. + */ +int64_t dirtylimit_us_ring_full(void) +{ + CPUState *cpu; + uint64_t curr_rate =3D 0; + int nvcpus =3D 0; + + CPU_FOREACH(cpu) { + if (cpu->running) { + nvcpus++; + curr_rate +=3D vcpu_dirty_rate_get(cpu->cpu_index); + } + } + + if (!curr_rate || !nvcpus) { + return -1; + } + + return dirtylimit_dirty_ring_full_time(curr_rate / nvcpus); +} + static struct DirtyLimitInfoList *dirtylimit_query_all(void) { int i, index; --=20 2.17.1