From nobody Wed Feb 11 06:31:40 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 1670087502780249.73814539457362; Sat, 3 Dec 2022 09:11:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p1W1p-0000oZ-Jj; Sat, 03 Dec 2022 12:10:17 -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 1p1W1j-0000jn-BX for qemu-devel@nongnu.org; Sat, 03 Dec 2022 12:10:11 -0500 Received: from prt-mail.chinatelecom.cn ([42.123.76.219] helo=chinatelecom.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p1W1f-0006jC-OZ for qemu-devel@nongnu.org; Sat, 03 Dec 2022 12:10:10 -0500 Received: from clientip-125.69.43.82 (unknown [172.18.0.218]) by chinatelecom.cn (HERMES) with SMTP id 72C282800B6; Sun, 4 Dec 2022 01:10:02 +0800 (CST) Received: from ([125.69.43.82]) by app0025 with ESMTP id c12095dbf81b4822b2957ec4f8cfd308 for qemu-devel@nongnu.org; Sun, 04 Dec 2022 01:10:05 CST HMM_SOURCE_IP: 172.18.0.218:60462.1823367042 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP X-189-SAVE-TO-SEND: +huangy81@chinatelecom.cn X-Transaction-ID: c12095dbf81b4822b2957ec4f8cfd308 X-Real-From: huangy81@chinatelecom.cn X-Receive-IP: 125.69.43.82 X-MEDUSA-Status: 0 From: huangy81@chinatelecom.cn To: qemu-devel Cc: Peter Xu , Markus Armbruster , "Dr. David Alan Gilbert" , Paolo Bonzini , Laurent Vivier , Eric Blake , Juan Quintela , Thomas Huth , Peter Maydell , Richard Henderson , =?UTF-8?q?Hyman=20Huang=28=E9=BB=84=E5=8B=87=29?= Subject: [PATCH RESEND v3 09/10] migration: Export dirty-limit time info for observation Date: Sun, 4 Dec 2022 01:09:12 +0800 Message-Id: <522bd838bcc4df6c232a240a71e5c2fa550f3f48.1670087276.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.219; 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: 1670087503030100001 From: Hyman Huang(=E9=BB=84=E5=8B=87) Export dirty limit throttle time and estimated ring full time, through which we can observe if dirty limit take effect during live migration. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- include/sysemu/dirtylimit.h | 2 ++ migration/migration.c | 10 ++++++++++ monitor/hmp-cmds.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 8d2c1f3..f15e01d 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_full(void); +int64_t dirtylimit_ring_full_time(void); #endif diff --git a/migration/migration.c b/migration/migration.c index 127d0fe..3f92389 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -62,6 +62,7 @@ #include "yank_functions.h" #include "sysemu/qtest.h" #include "sysemu/kvm.h" +#include "sysemu/dirtylimit.h" =20 #define MAX_THROTTLE (128 << 20) /* Migration transfer speed throttl= ing */ =20 @@ -1114,6 +1115,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_full =3D true; + info->dirty_limit_throttle_time_per_full =3D + dirtylimit_throttle_time_per_full(); + + 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/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 9ad6ee5..c3aaba3 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -339,6 +339,16 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) info->cpu_throttle_percentage); } =20 + if (info->has_dirty_limit_throttle_time_per_full) { + monitor_printf(mon, "dirty-limit throttle time: %" PRIi64 " us\n", + info->dirty_limit_throttle_time_per_full); + } + + 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/qapi/migration.json b/qapi/migration.json index 6055fdc..ae7d22d 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-full: Maximum throttle time (in microseco= nds) of virtual +# CPUs each dirty ring full round, us= ed to observe +# if dirty-limit take effect during l= ive migration. +# (since 7.3) +# +# @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 7.3) +# # 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-full': 'int64', + '*dirty-limit-ring-full-time': 'int64'} } =20 ## # @query-migrate: diff --git a/softmmu/dirtylimit.c b/softmmu/dirtylimit.c index b63032c..06de099 100644 --- a/softmmu/dirtylimit.c +++ b/softmmu/dirtylimit.c @@ -569,6 +569,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_full(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 1.8.3.1