From nobody Sat Nov 15 16:07:34 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1749486009; cv=none; d=zohomail.com; s=zohoarc; b=e9o4gXYU8Zsz8pIR26ILE7EKVGby9RDUzPp2QWNr6hbgL15YAzyQCc3KdnS7vXo9LhsjV1Rr5I0YZWtCF/KP4XsWYowxv7r4qiKimL/JFjaf13fuNCbo9NpTf+tfoM4vxClRAdf4eWOjLMCrM3S+L7i+2TolVwF6RqA7QYOKmHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749486009; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GftW69IoIvz/x1xZNVGzz01cczNmp8jYtfQ1Gtjwb0s=; b=Vbe9tK3uWL7j5hkoTeuYbmBI1tMmQJX8LfBP0sKCRPH5Jq+KFdZUoAgF7k4bt8+pFMOFZ8Z7YiueSajHLCOI9l6i9Ucoryh+X88QZ05aLbWmVPvrOP1JYPANOBEAyiysReMvJbfcfIYYIHlOj/Bzy1dtyWaCb2c8OZMDQTjWVew= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1749486009066446.3862260821635; Mon, 9 Jun 2025 09:20:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOfDH-0008LR-5r; Mon, 09 Jun 2025 12:19:07 -0400 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 1uOfDF-0008Ki-4R for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uOfDD-0004TS-2R for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:04 -0400 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-577-f6GpiiGCN8q2REjdlCZUgg-1; Mon, 09 Jun 2025 12:19:01 -0400 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6fad8b4c92cso120102506d6.0 for ; Mon, 09 Jun 2025 09:19:01 -0700 (PDT) Received: from x1.local ([85.131.185.92]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6fb09ab95c1sm53420546d6.15.2025.06.09.09.18.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jun 2025 09:18:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749485942; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GftW69IoIvz/x1xZNVGzz01cczNmp8jYtfQ1Gtjwb0s=; b=OYpcFNJeZYH0O1PbprcQheFZ3r1j8DfhabjtbjQR+YSqrI5nxsP4QS505xf0+i5B4mzSYO Vhno7ikpL9IyQ6x82rOHJ9w9Qg0kTZi6/RcrWvKWVIjiTrlC6qr4JvQyh5SOSpOedp51b7 QijABUT2J311alCf/uR5eVyK1aqt3cw= X-MC-Unique: f6GpiiGCN8q2REjdlCZUgg-1 X-Mimecast-MFC-AGG-ID: f6GpiiGCN8q2REjdlCZUgg_1749485941 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749485940; x=1750090740; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GftW69IoIvz/x1xZNVGzz01cczNmp8jYtfQ1Gtjwb0s=; b=NPeFrNMhnyvaw1O3EogS9AWFx0lk2szjLpeXPRL9otaqiQxcBLzYtMByP7H5Uhksca REYcrieNmVULrX0INRkMthL/sPFqh81J/G3ASavgltironf/bRApaHgdo7fc4ClyLu4W ib0Wff8nKg/f3UXzWp1RYS00P6dwPsg9jkB7iHf5lDWelBXVcyZmzBXEykaMtoFGuFfX TwNeu+Cra6ZIs9jQpz/VoxaEqnVXfYBRDN/6C6HSpgmbTTnCJdhgRhoSA75vrsvMi+5U bD+RqCroySsxfx78/eGAYCsApumOoat1w40siTKK7GxoLmcL9s5Wb/sTPdIXVUsO7+wS HBbA== X-Gm-Message-State: AOJu0YwMknAVE8WIXp9L74yTO4AqHE7jYIkl45GrG8G/7BCRNyFxH3sf kJwur7oY4apGf1SNicbWw1JfU8r9WryJr16WgqQaD+aCsC7GH9U4S5XXIda/Vpyxx3exOLXAk21 HlXCC6mlJFPPMmhN5JOabffmD+zAEXWzmwrLkZ2ABaUTJ7k1UMjXi3HtALLOKHnBQkjI/jQoGEC HxSxPQnnPJN2BO8CmkAZ132WiCCcS8yHcoJbHU9w== X-Gm-Gg: ASbGncsgTXZRkLl14itQgK9pWf4k09eiIXTiKzPSm7sIuKXj+eqsl37K8ACwvwhXNI8 LTiRJi+Qw0H1RPLyEX4u04R3J7XTtd9lxUWyhfr76NPp2Ua9chYHnK0awx9Z8hTJMJizTYW/Z9m iWohKE6B32wDDyCUIsuTRnRoTmqnBbh74FxujCKwgaZ9Edaet8iNe9UvZHNvgV5qDAtOtRJa49K x3OF7llxODcM61p8z4aw5aTZ4L5TitsBRSKkr9CKIdBGfvXaJbfwOdl0yP4bBKBtK1QJhYrXTyC ocjZ2+rVKXAasw== X-Received: by 2002:a05:6214:2602:b0:6f2:d25e:8f60 with SMTP id 6a1803df08f44-6fb08ff5e10mr211735876d6.22.1749485940047; Mon, 09 Jun 2025 09:19:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHnLeSdOx25LaY53ALmIXXVSy+ck5Ba7YjZp22VZpyisx34lDsQcaTnx0qjm0XMOIlWIMfRTQ== X-Received: by 2002:a05:6214:2602:b0:6f2:d25e:8f60 with SMTP id 6a1803df08f44-6fb08ff5e10mr211735476d6.22.1749485939646; Mon, 09 Jun 2025 09:18:59 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , peterx@redhat.com, "Dr . David Alan Gilbert" , Fabiano Rosas , Li Zhijian Subject: [PATCH v2 01/11] migration/hmp: Reorg "info migrate" once more Date: Mon, 9 Jun 2025 12:18:45 -0400 Message-ID: <20250609161855.6603-2-peterx@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250609161855.6603-1-peterx@redhat.com> References: <20250609161855.6603-1-peterx@redhat.com> MIME-Version: 1.0 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1749486011138116600 Content-Type: text/plain; charset="utf-8" Dave suggested the HMP output for "info migrate" can not only leverage the lines but also better grouping: https://lore.kernel.org/r/aC4_-nMc7FwsMf9p@gallifrey I followed Dave's suggestion, and some more modifications on top: - Added all elements into the picture - Use size_to_str() and drop most of the units: benefit is more friendly to most human eyes, bad side effect is lose of details, but that should be corner case per my uses, and one can still leverage the QMP interface when necessary. - Sub-grouping for "Transfers" ("Channels" and "Page Types"). - Better indentations Sample output: (qemu) info migrate Status: postcopy-active Time (ms): total=3D47317, setup=3D5, down=3D8 RAM info: Throughput (Mbps): 1342.83 Sizes: pagesize=3D4 KiB, total=3D4.02 GiB Transfers: transferred=3D1.41 GiB, remain=3D2.46 GiB Channels: precopy=3D15.2 MiB, multifd=3D0 B, postcopy=3D1.39 = GiB Page Types: normal=3D367713, zero=3D41195 Page Rates (pps): transfer=3D40900, dirty=3D4 Others: dirty_syncs=3D2, postcopy_req=3D57503 Suggested-by: Dr. David Alan Gilbert Tested-by: Li Zhijian Reviewed-by: Li Zhijian Acked-by: Dr. David Alan Gilbert Reviewed-by: Juraj Marcin Signed-off-by: Peter Xu Tested-by: Mario Casquero --- migration/migration-hmp-cmds.c | 59 ++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index e8a563c7d8..367ff6037f 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -69,7 +69,7 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) } =20 if (info->has_status) { - monitor_printf(mon, "Status: %s", + monitor_printf(mon, "Status: \t\t%s", MigrationStatus_str(info->status)); if (info->status =3D=3D MIGRATION_STATUS_FAILED && info->error_des= c) { monitor_printf(mon, " (%s)\n", info->error_desc); @@ -78,7 +78,7 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) } =20 if (info->total_time) { - monitor_printf(mon, "Time (ms): total=3D%" PRIu64, + monitor_printf(mon, "Time (ms): \t\ttotal=3D%" PRIu64, info->total_time); if (info->has_setup_time) { monitor_printf(mon, ", setup=3D%" PRIu64, @@ -110,48 +110,51 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdic= t) } =20 if (info->ram) { + g_autofree char *str_psize =3D size_to_str(info->ram->page_size); + g_autofree char *str_total =3D size_to_str(info->ram->total); + g_autofree char *str_transferred =3D size_to_str(info->ram->transf= erred); + g_autofree char *str_remaining =3D size_to_str(info->ram->remainin= g); + g_autofree char *str_precopy =3D size_to_str(info->ram->precopy_by= tes); + g_autofree char *str_multifd =3D size_to_str(info->ram->multifd_by= tes); + g_autofree char *str_postcopy =3D size_to_str(info->ram->postcopy_= bytes); + monitor_printf(mon, "RAM info:\n"); - monitor_printf(mon, " Throughput (Mbps): %0.2f\n", + monitor_printf(mon, " Throughput (Mbps): \t%0.2f\n", info->ram->mbps); - monitor_printf(mon, " Sizes (KiB): pagesize=3D%" PRIu64 - ", total=3D%" PRIu64 ",\n", - info->ram->page_size >> 10, - info->ram->total >> 10); - monitor_printf(mon, " transferred=3D%" PRIu64 - ", remain=3D%" PRIu64 ",\n", - info->ram->transferred >> 10, - info->ram->remaining >> 10); - monitor_printf(mon, " precopy=3D%" PRIu64 - ", multifd=3D%" PRIu64 - ", postcopy=3D%" PRIu64, - info->ram->precopy_bytes >> 10, - info->ram->multifd_bytes >> 10, - info->ram->postcopy_bytes >> 10); + monitor_printf(mon, " Sizes: \t\tpagesize=3D%s, total=3D%s\n", + str_psize, str_total); + monitor_printf(mon, " Transfers: \t\ttransferred=3D%s, remain=3D%= s\n", + str_transferred, str_remaining); + monitor_printf(mon, " Channels: \t\tprecopy=3D%s, " + "multifd=3D%s, postcopy=3D%s", + str_precopy, str_multifd, str_postcopy); =20 if (info->vfio) { - monitor_printf(mon, ", vfio=3D%" PRIu64, - info->vfio->transferred >> 10); + g_autofree char *str_vfio =3D size_to_str(info->vfio->transfer= red); + + monitor_printf(mon, ", vfio=3D%s", str_vfio); } monitor_printf(mon, "\n"); =20 - monitor_printf(mon, " Pages: normal=3D%" PRIu64 ", zero=3D%" PRIu= 64 - ", rate_per_sec=3D%" PRIu64 "\n", - info->ram->normal, - info->ram->duplicate, + monitor_printf(mon, " Page Types: \tnormal=3D%" PRIu64 + ", zero=3D%" PRIu64 "\n", + info->ram->normal, info->ram->duplicate); + monitor_printf(mon, " Page Rates (pps): \ttransfer=3D%" PRIu64, info->ram->pages_per_second); - monitor_printf(mon, " Others: dirty_syncs=3D%" PRIu64, - info->ram->dirty_sync_count); - if (info->ram->dirty_pages_rate) { - monitor_printf(mon, ", dirty_pages_rate=3D%" PRIu64, + monitor_printf(mon, ", dirty=3D%" PRIu64, info->ram->dirty_pages_rate); } + monitor_printf(mon, "\n"); + + monitor_printf(mon, " Others: \t\tdirty_syncs=3D%" PRIu64, + info->ram->dirty_sync_count); if (info->ram->postcopy_requests) { monitor_printf(mon, ", postcopy_req=3D%" PRIu64, info->ram->postcopy_requests); } if (info->ram->downtime_bytes) { - monitor_printf(mon, ", downtime_ram=3D%" PRIu64, + monitor_printf(mon, ", downtime_bytes=3D%" PRIu64, info->ram->downtime_bytes); } if (info->ram->dirty_sync_missed_zero_copy) { --=20 2.49.0 From nobody Sat Nov 15 16:07:34 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1749485999; cv=none; d=zohomail.com; s=zohoarc; b=bDFCOLe9eYF6QxNvpAer2I7NT0z2dEj18hfZMt3D7gtM0xm+q61isQFuuYYuDtOBgeI0RW27pMBONdjiVT3G2NI8IYDzPHWYxQ6fAX8hTlFbB7X9Mdhn+TKBEqD+rjiJvbBdodUtH3dP/xmO7kox7UcuYVmDT46DR7N3bIFmwsc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749485999; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fky2C5XWssldCauVD5W1cOCcRd8P/NgdIIozgxtj3dI=; b=Kh4WdGS4eoKzueEAHk7/ZnxCcJ3EO0ENlByTCZB9pCL1dJtl99EBx2HUZVQ0UIVTZk8Gl1MuDg8ek9wTKHpHH0CxMTcO/pq+wzBaauzJPYy31LbB9gxZg6/fCSFMmaa1BSd7onFlrS2JRM66vp0KPHXOd15NF5cmQHJq08HHI0Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1749485999030924.3659362526912; Mon, 9 Jun 2025 09:19:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOfDJ-0008OF-0z; Mon, 09 Jun 2025 12:19:09 -0400 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 1uOfDG-0008LF-Up for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uOfDF-0004TX-1T for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:06 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-MSV9l6TDMfGIGLpJWX0BjA-1; Mon, 09 Jun 2025 12:19:02 -0400 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6fad1f7f175so77166316d6.1 for ; Mon, 09 Jun 2025 09:19:02 -0700 (PDT) Received: from x1.local ([85.131.185.92]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6fb09ab95c1sm53420546d6.15.2025.06.09.09.18.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jun 2025 09:19:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749485943; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fky2C5XWssldCauVD5W1cOCcRd8P/NgdIIozgxtj3dI=; b=hoIoHBQWk8f9z2qTZeeADIG9FLz1RMYuDxXFLsZCEAZ9jOEFLccTIBsmZpVs4dFzzYTDPF VzHCueD+nVNA2hYqVpFQrMe9NvlgwCAHsBRDu+Ppx5pFQQcipNXWxNmGxR4FKxOmTfDvJr MjWFb4zvHskSaAJt7d3ZU9l/Zswn4sM= X-MC-Unique: MSV9l6TDMfGIGLpJWX0BjA-1 X-Mimecast-MFC-AGG-ID: MSV9l6TDMfGIGLpJWX0BjA_1749485942 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749485942; x=1750090742; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fky2C5XWssldCauVD5W1cOCcRd8P/NgdIIozgxtj3dI=; b=tv6J7kwc8f7c21yYkpi4ZhcULcJ9a8eHmwtyhJLmbB4m2prdRbh8e51tgpC9zBJUOX mGqA8UpHPFIytJF9Mpc/VB73fA5f7dJvVEiKgNLhJFPvCQSK6EaJKLxt4jA5kF9oY9gH UgiRqairXGLtKhinb4AHeVgPHl7C6++9nVIxnpOSdMwaCJWDfMER9XLKEE+3Ofkjg4fw yCfLzt9cI136S/y3NSsl2JXYeC6kHp3Ksempxl7BbCy6t2DyErBlCtXvVXNYRuMEO2vp a4j3ZgCOPkmEC5QQBBSEpVetj1iSQX+xsYLgUH/vZANPbiTKc7wVcvWxNois9VgvhjGQ X8ng== X-Gm-Message-State: AOJu0YzzVWXHI/xGjtgzj/UuatGeh+4idQtMTI2RQOnRgO/OPlXyoXoj RH2M5UK13QMmDvuPRn454A1jrIKQEJS1pKsuQFx3ZRwhdHjOf/2/m94roQ3dENsdDrWYgTxnT4/ T3KsbSb+v5PM8ZCjXUAmN7u1ySnu8er0dtkQMo3zJ92rfTh0BMnDSslP5WTL+Elb8OSmzZ9M1dk PPizLSm8SmKblulKWgm8ZfBQgSDcvJf70oCxU4yQ== X-Gm-Gg: ASbGncswr6hS3nsDWE9dWTn9gkvLiidGDZz+ir8lf9JZCbDf/ybAGRPX8rTSbuDoC88 lXALVfEMLSX45s6h/NKGNM002+92AcBuhgec9teMIWzUR2AkygYqH/DO3gJEDlxYEbXA4QdXHfN zHy0mKpPHVfg9i2QDEMrCN3EZj50ZLt/JMd0usAAprmeqvHxqSe5iFDdzWMCb00gkkf/E0BRFsI LW/gMGtFeqv0vFqALEwG4P+dDpgNA7yAxq0uN97czqf5w/UABfSZheEqoE2QvPQL24lsTwk3fOK PA8cD60qMnm9wA== X-Received: by 2002:a05:6214:2528:b0:6fa:c5f8:67eb with SMTP id 6a1803df08f44-6fb238f9aabmr2669786d6.7.1749485941736; Mon, 09 Jun 2025 09:19:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHcP18+WsNalRNu2/tcyVRidhsxOvxsTs15WXoURMIAiJ3ayVC/WnWpRosa/qSCncq3O79cOg== X-Received: by 2002:a05:6214:2528:b0:6fa:c5f8:67eb with SMTP id 6a1803df08f44-6fb238f9aabmr2669146d6.7.1749485941234; Mon, 09 Jun 2025 09:19:01 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , peterx@redhat.com, "Dr . David Alan Gilbert" , Fabiano Rosas , Alexey Perevalov , Markus Armbruster Subject: [PATCH v2 02/11] migration/hmp: Fix postcopy-blocktime per-vCPU results Date: Mon, 9 Jun 2025 12:18:46 -0400 Message-ID: <20250609161855.6603-3-peterx@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250609161855.6603-1-peterx@redhat.com> References: <20250609161855.6603-1-peterx@redhat.com> MIME-Version: 1.0 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1749486001077116600 Content-Type: text/plain; charset="utf-8" Unfortunately, it was never correctly shown.. This is only found when I started to look into making the blocktime feature more useful (so as to avoid using bpftrace, even though I'm not sure which one will be harder to use..). So the old dump would look like this: Postcopy vCPU Blocktime: 0-1,4,10,21,33,46,48,59 Even though there're actually 40 vcpus, and the string will merge same elements and also sort them. To fix it, simply loop over the uint32List manually. Now it looks like: Postcopy vCPU Blocktime (ms): [15, 0, 0, 43, 29, 34, 36, 29, 37, 41, 33, 37, 45, 52, 50, 38, 40, 37, 40, 49, 40, 35, 35, 35, 81, 19, 18, 19, 18, 30, 22, 3, 0, 0, 0, 0, 0, 0, 0, 0] Cc: Dr. David Alan Gilbert Cc: Alexey Perevalov Cc: Markus Armbruster Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas Tested-by: Mario Casquero --- migration/migration-hmp-cmds.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index 367ff6037f..6c36e202a0 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -208,15 +208,19 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdic= t) } =20 if (info->has_postcopy_vcpu_blocktime) { - Visitor *v; - char *str; - v =3D string_output_visitor_new(false, &str); - visit_type_uint32List(v, NULL, &info->postcopy_vcpu_blocktime, - &error_abort); - visit_complete(v, &str); - monitor_printf(mon, "Postcopy vCPU Blocktime: %s\n", str); - g_free(str); - visit_free(v); + uint32List *item =3D info->postcopy_vcpu_blocktime; + const char *sep =3D ""; + int count =3D 0; + + monitor_printf(mon, "Postcopy vCPU Blocktime (ms): \n ["); + + while (item) { + monitor_printf(mon, "%s%"PRIu32, sep, item->value); + item =3D item->next; + /* Each line 10 vcpu results, newline if there's more */ + sep =3D ((++count % 10 =3D=3D 0) && item) ? ",\n " : ", "; + } + monitor_printf(mon, "]\n"); } =20 out: --=20 2.49.0 From nobody Sat Nov 15 16:07:34 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1749486071; cv=none; d=zohomail.com; s=zohoarc; b=LKlV4KzVsChE7f2KTxFVF1afBoo/smctVPkc5ID9Sli6D0tgbKyKcDyDKKWldmVL59VMt+hm3zUgPx1vdOIEmNG9lTeYRyKsfDQ1Jvfmkb0JQKXQD6LfY+RVphg2l1BEX1WjWqp03bBPA04LmA+EFSIjS9yfNLAo6Gygh3On7WA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749486071; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hT+PxuMKRJ8Bh39RMhUF6/Cm7/wGAILL/wn1CqdT0Rg=; b=aKxewyCGjlQt85jBHbw464XrPoj3TRWyby7YMBM865G3pHaxCcESkYVgFlppr6es2O53FfFYOgZdGNpwwy7NHAesxX3EZmEyaMV3dvsrcXugGrz3fwxeTvS/GBSDSBCc1lxqNaF0585hNWFCTf8MN/YURVzD8hrwjeVz7py6ovs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1749486071890802.0581849411511; Mon, 9 Jun 2025 09:21:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOfDK-0008PY-1r; Mon, 09 Jun 2025 12:19:10 -0400 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 1uOfDI-0008Nl-AE for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uOfDG-0004Tr-NF for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:08 -0400 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-362-0t6EcvsZNwWYUL2edn094Q-1; Mon, 09 Jun 2025 12:19:04 -0400 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6fafca0971cso80309806d6.0 for ; Mon, 09 Jun 2025 09:19:04 -0700 (PDT) Received: from x1.local ([85.131.185.92]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6fb09ab95c1sm53420546d6.15.2025.06.09.09.19.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jun 2025 09:19:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749485945; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hT+PxuMKRJ8Bh39RMhUF6/Cm7/wGAILL/wn1CqdT0Rg=; b=a4Zl1/voEKwusfZoWVJyU7l/YT1ltThnZerVFOt68eSm4Xey4sCumwKwvolwww0uzFyx46 ZrT/Nvh75CQ2FShNyB+x3aRNfzzkTwVpBH+L2iGP8Lnx1xHFgUqygOI+Z4lflcDl33ceQW fP5rdC9GLC0hhljxv1EeSGK/k0m1y20= X-MC-Unique: 0t6EcvsZNwWYUL2edn094Q-1 X-Mimecast-MFC-AGG-ID: 0t6EcvsZNwWYUL2edn094Q_1749485944 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749485944; x=1750090744; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hT+PxuMKRJ8Bh39RMhUF6/Cm7/wGAILL/wn1CqdT0Rg=; b=jO3eWxAMMcyl6TksAmbAMv6B9kIwkY8Wnx4kvq5cvys2Fp9yviPmzHWgOhOIPR25EQ mEQgqz8kZP5+QuDb1UcdRaeFD6md6pS4a3pTvQq87jSyxVcZOPsufYsG8H9yzWgnl1jj kxM97bikpzi/cgtaAjaRG8yfGaaxsRo9hYCN73J3aMLOltYhJLk0NWSqjogejNcjybKg yImSjj9ttMU25WIb0vda4TED2Yxju9/o/417i9agV7rQ+WkRBortIb0SnpfWDUICr52j Sz0K8+1kW9h/5Y5jgFK7g51RaqMT179PCkoVA8jgv0SITMxH2Vu+hdQAGNHorYW6jg8r Ootw== X-Gm-Message-State: AOJu0Yyf7/U9RYrdxSC2usCPWIGVtOX85kKqmSI2d1ch6Mf+a2PKWqa6 qVIbERW+w+FzJ3xITcYZ7u1OptMy1R6B6rktsMRgeMcNKwL3yk9ZZh0nlIcWhhjTrVD0DQf8C5z tNH3adoCVAwuuLuf/RmoXAYvMlVQY4gl/Kzfvv4UOW2g2YWs82Nxj3+gR9XSLC/zERfbYEoI8Hu L9Hj+vtLccxqZMXFf7EDNp7cf+Em5jcdLtciiZ9Q== X-Gm-Gg: ASbGncuAzgtpGV6frjAhrZZLYDpcdYuuzr5idPDBGXCy1aWLmeJsoaWphhVh0vwNlKe m6XqrUx49zOANbMy38FY/Mv2MV59fnWvWoAgFGxgzaauxAI8Ak95O91GVqfdNOPbeDqXaq3Kgi/ wqY8ZyQd8ua/Zn/8RbRiNUdcydDd0wRvcEyr8G3fO4f2Hznst8zFM47b2FoyJh1+vtbfkKl3vJO KurxPJyFfmICn+x9q09Gt4q4QCBq2/MS4zUvPh3IycJeh41SXWhT49114RVjtM0lGWScv+ZjIKa hCo= X-Received: by 2002:a05:6214:226d:b0:6f2:a4cf:5fd7 with SMTP id 6a1803df08f44-6fb0903f125mr234169746d6.45.1749485943713; Mon, 09 Jun 2025 09:19:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDFAtJ+oIhAKqZO5TOGwU7PZ0gt7EFwbL5stBG87K9+9yyZkIljqZxh9TQMb703j33haU+xg== X-Received: by 2002:a05:6214:226d:b0:6f2:a4cf:5fd7 with SMTP id 6a1803df08f44-6fb0903f125mr234168816d6.45.1749485942879; Mon, 09 Jun 2025 09:19:02 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , peterx@redhat.com, "Dr . David Alan Gilbert" , Fabiano Rosas Subject: [PATCH v2 03/11] migration/docs: Move docs for postcopy blocktime feature Date: Mon, 9 Jun 2025 12:18:47 -0400 Message-ID: <20250609161855.6603-4-peterx@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250609161855.6603-1-peterx@redhat.com> References: <20250609161855.6603-1-peterx@redhat.com> MIME-Version: 1.0 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1749486073839116600 Content-Type: text/plain; charset="utf-8" Move it out of vanilla postcopy session, but instead a standalone feature. When at it, removing the NOTE because it's incorrect now after introduction of max-postcopy-bandwidth, which can control the throughput even for postcopy phase. Reviewed-by: Juraj Marcin Signed-off-by: Peter Xu Tested-by: Mario Casquero --- docs/devel/migration/postcopy.rst | 36 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/docs/devel/migration/postcopy.rst b/docs/devel/migration/postc= opy.rst index 82e7a848c6..e319388d8f 100644 --- a/docs/devel/migration/postcopy.rst +++ b/docs/devel/migration/postcopy.rst @@ -33,25 +33,6 @@ will now cause the transition from precopy to postcopy. It can be issued immediately after migration is started or any time later on. Issuing it after the end of a migration is harmless. =20 -Blocktime is a postcopy live migration metric, intended to show how -long the vCPU was in state of interruptible sleep due to pagefault. -That metric is calculated both for all vCPUs as overlapped value, and -separately for each vCPU. These values are calculated on destination -side. To enable postcopy blocktime calculation, enter following -command on destination monitor: - -``migrate_set_capability postcopy-blocktime on`` - -Postcopy blocktime can be retrieved by query-migrate qmp command. -postcopy-blocktime value of qmp command will show overlapped blocking -time for all vCPU, postcopy-vcpu-blocktime will show list of blocking -time per vCPU. - -.. note:: - During the postcopy phase, the bandwidth limits set using - ``migrate_set_parameter`` is ignored (to avoid delaying requested pages = that - the destination is waiting for). - Postcopy internals =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 @@ -312,3 +293,20 @@ explicitly) to be sent in a separate preempt channel, = rather than queued in the background migration channel. Anyone who cares about latencies of page faults during a postcopy migration should enable this feature. By default, it's not enabled. + +Postcopy blocktime statistics +----------------------------- + +Blocktime is a postcopy live migration metric, intended to show how +long the vCPU was in state of interruptible sleep due to pagefault. +That metric is calculated both for all vCPUs as overlapped value, and +separately for each vCPU. These values are calculated on destination +side. To enable postcopy blocktime calculation, enter following +command on destination monitor: + +``migrate_set_capability postcopy-blocktime on`` + +Postcopy blocktime can be retrieved by query-migrate qmp command. +postcopy-blocktime value of qmp command will show overlapped blocking +time for all vCPU, postcopy-vcpu-blocktime will show list of blocking +time per vCPU. --=20 2.49.0 From nobody Sat Nov 15 16:07:34 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1749485963; cv=none; d=zohomail.com; s=zohoarc; b=SPJxjB8KcC/7sg8YWpD+OWzG02Fp29hcj+Ond63QAn5jem0E/LE9hDxOoffHDmEfHKmcDIjPzVBiKRssCwzE4unm4w7LnMB+J2gI1mYaVz6SObPd+lYNtBmdB/4tiAUC8uRMJVAosRX7e+Lp+JfLXNpc6Xt6Ay+AMyD1ZzGgsXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749485963; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cDCSHE7UZto1NWz1vjWrhDSXJj9UdV9w/vzQlY4ASS0=; b=iCobwmW9z2585ws3Lwv0QscXJyUQIuBrNIfav5zZVdWW+3rt22ZEizxJalCMnMiEDISfo7gfEvztPspoXvXiQcn57zojOdJNZn0bc21WJ7CwjkXZ8XI/Rc3EiLs7FHLAuQK0UXNyZ3ROn2P1FdB3wp2RsmhPJc8tTbj6fc7ZQ84= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1749485963137183.6699292780553; Mon, 9 Jun 2025 09:19:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOfDM-0008Tj-8j; Mon, 09 Jun 2025 12:19:12 -0400 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 1uOfDJ-0008ON-1X for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uOfDH-0004U0-FN for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:08 -0400 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-550-dgjchpKsPcqjUIDnAUdmvQ-1; Mon, 09 Jun 2025 12:19:05 -0400 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6fb1f84a448so7772496d6.0 for ; Mon, 09 Jun 2025 09:19:05 -0700 (PDT) Received: from x1.local ([85.131.185.92]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6fb09ab95c1sm53420546d6.15.2025.06.09.09.19.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jun 2025 09:19:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749485946; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cDCSHE7UZto1NWz1vjWrhDSXJj9UdV9w/vzQlY4ASS0=; b=O7gG/M5p4zxPECmBo5fgLZd/SLfpi7Q+OV0CANhfwvhsqNcETbDbBqXCGxaYBtLtTgG3oX FR8jNvZZiXVeCDKqcuOdYhPYtooI3BqNZE5mQfzFQdAMrLpsJvvyQ/Aa1j6bUsW9WTcw2h VwMqR98YhcpJp6n3NmKdosavRqpwhiA= X-MC-Unique: dgjchpKsPcqjUIDnAUdmvQ-1 X-Mimecast-MFC-AGG-ID: dgjchpKsPcqjUIDnAUdmvQ_1749485945 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749485945; x=1750090745; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cDCSHE7UZto1NWz1vjWrhDSXJj9UdV9w/vzQlY4ASS0=; b=T3NY7Y0p/Y3Fkk4FOenPSmb8rg3n9Zp7mH60EZjOaGp023/b/+uat6jC/RpkL5A9JG ovLxxT16pXs8gZRB4pr/kXGe4M56FaDfWzSi2Kgoq6LQFZsVgjDMws45w5kGwwp2KZh6 uGjsxDbzKqZsiKiOv4Ir24tybGtYGcycMZuf/RULcbaHu69YGHQX00/tBLjeMVFkSnLD NvzlXvVxUVUi+9fmpsB9RUw52Z464lty4gZc/GnryiukBBAPKMOI0+F+xGOMS5F/aFTv TxEHrJtxY6UIig/7JOpWKXC0DNdZIH5hqiKVVd0BECmPjDi/cVtPjafpr/R1UslXoMo2 94eg== X-Gm-Message-State: AOJu0YzCdmalBMmLIdTU72Rmrzf/tgSPfSiNyGSma0X9L38zv/cFPykN BB46Dwh6HjaqniwJ0JKZDUgXAEAemZUS1qL31XumkCbI66amzufwB4HnncC7Q+hrSzlDDL6GMHv 9DLKXNK7mFv06Ot/hvc1tcoMlO8hQleQHo4o1udv2PA9lToYqxudKdlrYwwV3VjG1d/kcy7uCof ZepZBrKqN1a+t9aG1RNRyIUojow1QecMXpcwl2Lg== X-Gm-Gg: ASbGnctaNL0uNwnSpyTLPJ8h2am52TvWpN9v8bQKARGDkGq9OZPHYG3fnZgdzjSP2+P YDeb0ZsjkpQnggwoH+TMzXLvECpHLwxxvtcR1qlPgqEdrrnHLx2KuUlh7fu0ca+aE/Cn2vK62ry RFApv/0rUja1YZ/nfbjveaT0Y9VrPpMjTimvpMBAuIrdye8xACvEsxzD/+MFR4qKxsACrWNOMlA HSxLqJ+fwwW0D3U+KWfhEqJSbZWHdwY0vl1owYBAk/vo05WUSwcn9ZnfjOrLKcGvKAbzF802XUv FjxwTA1GaRMo6w== X-Received: by 2002:a05:6214:d68:b0:6fa:ccb6:6036 with SMTP id 6a1803df08f44-6fb08f8d31fmr217734006d6.35.1749485944641; Mon, 09 Jun 2025 09:19:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IErobSbYOP8oWeS9RDsAXGUPZIAOJdLibvL5y6Ss1B80VuId+QxeBBsQPHt/ImkJHS9JaYocg== X-Received: by 2002:a05:6214:d68:b0:6fa:ccb6:6036 with SMTP id 6a1803df08f44-6fb08f8d31fmr217733226d6.35.1749485943949; Mon, 09 Jun 2025 09:19:03 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , peterx@redhat.com, "Dr . David Alan Gilbert" , Fabiano Rosas Subject: [PATCH v2 04/11] migration/bg-snapshot: Do not check for SKIP in iterator Date: Mon, 9 Jun 2025 12:18:48 -0400 Message-ID: <20250609161855.6603-5-peterx@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250609161855.6603-1-peterx@redhat.com> References: <20250609161855.6603-1-peterx@redhat.com> MIME-Version: 1.0 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1749485964487116600 Content-Type: text/plain; charset="utf-8" It's not possible to happen in bg-snapshot case. Reviewed-by: Juraj Marcin Signed-off-by: Peter Xu Tested-by: Mario Casquero --- migration/migration.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 4098870bce..e33e39ac74 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3887,9 +3887,8 @@ static void *bg_migration_thread(void *opaque) =20 while (migration_is_active()) { MigIterateState iter_state =3D bg_migration_iteration_run(s); - if (iter_state =3D=3D MIG_ITERATE_SKIP) { - continue; - } else if (iter_state =3D=3D MIG_ITERATE_BREAK) { + + if (iter_state =3D=3D MIG_ITERATE_BREAK) { break; } =20 --=20 2.49.0 From nobody Sat Nov 15 16:07:34 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1749486035; cv=none; d=zohomail.com; s=zohoarc; b=cjHVdIwwNB5j03Uxm+mlQeubsTVGYC0pc3oaCb8ZtfWJHQi3iZBYQ7Ont+jpRERpDk4IGQKyWKZmaPVqnMVQjT2tWwG6dkVwjLq+Sk5SUjPAd8aysxkDkPoM2NlhZHHm10yLkqzsKuqCnIHcyUPyha5yyE2mZXa13Odtha6Y3xg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749486035; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NnxHrY3AJ2xlwMfJ+++pzxNv1sP7IaifMp2sR6DUt4w=; b=JPHMcfeTRUM7wUnJ0PBNKkCiZnd/B4/60VZJxPu610mrl8Ogp71lBztJp0qR11WUobuwAdjuqd3LvQ8ehR36LdkCv0bcPr8502BXvF7bnaxlGZqNBLm7WnjwcABXCxQvvQp5ZQ4ovzbi2A+rytPNHfmBNEqsYqgIgwuuPx4Wu7Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1749486035447444.9269324074436; Mon, 9 Jun 2025 09:20:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOfDN-00004z-KH; Mon, 09 Jun 2025 12:19:13 -0400 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 1uOfDL-0008Q7-59 for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uOfDJ-0004UI-E8 for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:10 -0400 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-636-kNc7-JLBOoqqQJU6hkdtpg-1; Mon, 09 Jun 2025 12:19:07 -0400 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6fac71417c2so74564106d6.0 for ; Mon, 09 Jun 2025 09:19:07 -0700 (PDT) Received: from x1.local ([85.131.185.92]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6fb09ab95c1sm53420546d6.15.2025.06.09.09.19.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jun 2025 09:19:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749485948; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NnxHrY3AJ2xlwMfJ+++pzxNv1sP7IaifMp2sR6DUt4w=; b=LqQt5ZI/NDBIORlrqazF147A1CtocWiU2kuR9VBi65SbB/3wEj5gxDGaO9/Izd2fQ0tMjM kWTsYtWedEsouhEoVM4CE0dAJ5aNs5iFhkN0SPaCVLeZ2ls1TBdvDekSs4a0BOwWFB5L73 7xma5ZQSMpVSMzPVNI0x22wPxFJ+o9g= X-MC-Unique: kNc7-JLBOoqqQJU6hkdtpg-1 X-Mimecast-MFC-AGG-ID: kNc7-JLBOoqqQJU6hkdtpg_1749485947 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749485947; x=1750090747; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NnxHrY3AJ2xlwMfJ+++pzxNv1sP7IaifMp2sR6DUt4w=; b=GfR48ndmMOTddUZaZv9Hoikr0Sh/H5EN9ifqCXdF3NVidfFiHDc74ET8cqJqUrjmFY kdskUInFpVx/AYAH6+ZdlCedN7xGx7QXsI+1IT390orvlATco5YZ4xoA2gLMJ6wpxGe9 kOMemh9HzChmvthXQOboJeEh4+3AZB5C6DH6d9ZXCHwGQVwiBs81qshyyJIwkD+azB6q BiN5fj9gSQiYkhxVUg54IEy5ZaoZgCBWouMuey3b22GMf+UlF6tgAcP+iN4GurR72E8D h6toGJ8eIynwlMU4zNWlRHBR8MbKNc3vK26GpbeAIjuwYrJbgizYktIfux1WqwEt7vGQ yLUw== X-Gm-Message-State: AOJu0YwIfvgytETQ1bDhuX5oldFiIBpVj7YH4oaStWnmkCLJ92JcjN5j tvjx/Gv8OmTej4lvHj5WTFD8C27GCFORAZ2h7gkKtRPkAVVxsOCe6SGlnk5z8xpQtQ+kuhVUHqo NSi6IscXNtgQ5PN5PNO1YR+kG4dcuerjkg8WoZ2JQpqMpOQZ+ennZm08iqk35ZUTnlJT6AX25Jz oIiU+HsFXRpnZLyPcLGGi5MVK5Dwk2pEiOCYBSEA== X-Gm-Gg: ASbGnctqZV1A7Onq6OqpVlEazpxHCR+nzxApndAPjnYe3AITjOsceQJdUr5AiIDjhuI HBbT6ljV0n975cYPnbd6YVEDHgjjX55fyloqi/TtLy67+O61ASm9o66dPOXwW6XH0YRFqjrWEg7 dsIwohDEAe9XHiUgN+ezkcma9wZ7O98WJ6/5kda5qXW4KvkuLlgerrZxO5uCh+DGAJmwkDwfVHh uQcLq+r7EktQQkkswcf8o9NCP4MlsfSC0F7zcu2mkUJeUrEHVF7GSm/1AhcuOUrpVud3akueVr0 laNFwUYCv/8rzA== X-Received: by 2002:a05:6214:2426:b0:6fa:ba15:e8a with SMTP id 6a1803df08f44-6fb08f528f2mr247163246d6.8.1749485946435; Mon, 09 Jun 2025 09:19:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFdR9M9mqDnSkJ0Ov1KR09buxe0cj4YRwBACfz3UNZTaymfuPunJEKUtdyFpauNG2MC8rRDtg== X-Received: by 2002:a05:6214:2426:b0:6fa:ba15:e8a with SMTP id 6a1803df08f44-6fb08f528f2mr247162256d6.8.1749485945689; Mon, 09 Jun 2025 09:19:05 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , peterx@redhat.com, "Dr . David Alan Gilbert" , Fabiano Rosas Subject: [PATCH v2 05/11] migration: Drop save_live_complete_postcopy hook Date: Mon, 9 Jun 2025 12:18:49 -0400 Message-ID: <20250609161855.6603-6-peterx@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250609161855.6603-1-peterx@redhat.com> References: <20250609161855.6603-1-peterx@redhat.com> MIME-Version: 1.0 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1749486037346116600 Content-Type: text/plain; charset="utf-8" The hook is only defined in two vmstate users ("ram" and "block dirty bitmap"), meanwhile both of them define the hook exactly the same as the precopy version. Hence, this postcopy version isn't needed. No functional change intended. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas Tested-by: Mario Casquero --- include/migration/register.h | 24 ++++++++---------------- migration/block-dirty-bitmap.c | 1 - migration/ram.c | 1 - migration/savevm.c | 9 ++++----- 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/include/migration/register.h b/include/migration/register.h index b79dc81b8d..e022195785 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -77,26 +77,18 @@ typedef struct SaveVMHandlers { */ void (*save_cleanup)(void *opaque); =20 - /** - * @save_live_complete_postcopy - * - * Called at the end of postcopy for all postcopyable devices. - * - * @f: QEMUFile where to send the data - * @opaque: data pointer passed to register_savevm_live() - * - * Returns zero to indicate success and negative for error - */ - int (*save_live_complete_postcopy)(QEMUFile *f, void *opaque); - /** * @save_live_complete_precopy * * Transmits the last section for the device containing any - * remaining data at the end of a precopy phase. When postcopy is - * enabled, devices that support postcopy will skip this step, - * where the final data will be flushed at the end of postcopy via - * @save_live_complete_postcopy instead. + * remaining data at the end phase of migration. + * + * For precopy, this will be invoked _during_ the switchover phase + * after source VM is stopped. + * + * For postcopy, this will be invoked _after_ the switchover phase + * (except some very unusual cases, like PMEM ramblocks), while + * destination VM can be running. * * @f: QEMUFile where to send the data * @opaque: data pointer passed to register_savevm_live() diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index f2c352d4a7..6ee3c32a76 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -1248,7 +1248,6 @@ static bool dirty_bitmap_has_postcopy(void *opaque) =20 static SaveVMHandlers savevm_dirty_bitmap_handlers =3D { .save_setup =3D dirty_bitmap_save_setup, - .save_live_complete_postcopy =3D dirty_bitmap_save_complete, .save_live_complete_precopy =3D dirty_bitmap_save_complete, .has_postcopy =3D dirty_bitmap_has_postcopy, .state_pending_exact =3D dirty_bitmap_state_pending, diff --git a/migration/ram.c b/migration/ram.c index fd8d83b63c..8b43b9e1e8 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4545,7 +4545,6 @@ void postcopy_preempt_shutdown_file(MigrationState *s) static SaveVMHandlers savevm_ram_handlers =3D { .save_setup =3D ram_save_setup, .save_live_iterate =3D ram_save_iterate, - .save_live_complete_postcopy =3D ram_save_complete, .save_live_complete_precopy =3D ram_save_complete, .has_postcopy =3D ram_has_postcopy, .state_pending_exact =3D ram_state_pending_exact, diff --git a/migration/savevm.c b/migration/savevm.c index 52105dd2f1..dfb67bf679 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1485,9 +1485,8 @@ bool should_send_vmdesc(void) } =20 /* - * Calls the save_live_complete_postcopy methods - * causing the last few pages to be sent immediately and doing any associa= ted - * cleanup. + * Complete saving any postcopy-able devices. + * * Note postcopy also calls qemu_savevm_state_complete_precopy to complete * all the other devices, but that happens at the point we switch to postc= opy. */ @@ -1497,7 +1496,7 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f) int ret; =20 QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { - if (!se->ops || !se->ops->save_live_complete_postcopy) { + if (!se->ops || !se->ops->save_live_complete_precopy) { continue; } if (se->ops->is_active) { @@ -1510,7 +1509,7 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f) qemu_put_byte(f, QEMU_VM_SECTION_END); qemu_put_be32(f, se->section_id); =20 - ret =3D se->ops->save_live_complete_postcopy(f, se->opaque); + ret =3D se->ops->save_live_complete_precopy(f, se->opaque); trace_savevm_section_end(se->idstr, se->section_id, ret); save_section_footer(f, se); if (ret < 0) { --=20 2.49.0 From nobody Sat Nov 15 16:07:34 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1749486028; cv=none; d=zohomail.com; s=zohoarc; b=Eai3zRoH5gQboJ54fJpDwpT4xR+Eue7vJgogNM94vDxGz1VYX1MFgbmtiP0czw8v3G14iLt3CpzId6+mfOXc75xMu5RvP4Mr4csBEbgeRs4l1a8qwgrcAwKnlR9BcTqtxlGKtUFIePu9lrgaNAyT9yipbY9IHas92z1sNFEc6Bo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749486028; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=E2XIrWaj9CYKaBSgFOHuJujnQV0+UP1da/Qg7ZHotwM=; b=WH+O6PM8y3Sa7zDLbWk7WJ6Jfq7wm76GpJJBGsPMnlr2EdHdgbD4EB+aNqnEaaIGZnnvlyGdefylsg3wv9ZZuxsow+HF2k8+Jz7iYyU6VfUBVywbspu+35wsP1PbPjWBbUSN563Y7U0IKYdpHkzk5INnWmV08X9+ZvjMEpNQeiY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1749486028423401.2591333552482; Mon, 9 Jun 2025 09:20:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOfDO-000072-HU; Mon, 09 Jun 2025 12:19:14 -0400 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 1uOfDM-0008TN-1s for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uOfDK-0004UT-7q for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:11 -0400 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-467-mrFf8H7uNkS7B5Ikl1564A-1; Mon, 09 Jun 2025 12:19:08 -0400 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-4a589edc51aso110240671cf.0 for ; Mon, 09 Jun 2025 09:19:08 -0700 (PDT) Received: from x1.local ([85.131.185.92]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6fb09ab95c1sm53420546d6.15.2025.06.09.09.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jun 2025 09:19:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749485949; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E2XIrWaj9CYKaBSgFOHuJujnQV0+UP1da/Qg7ZHotwM=; b=iRcNtdtFA3xo5EZvrLdoZIA68Td1aQ6wWz9KUv97kC8a8Fkeus/3/D0LTpCACnu9m0oLlN ikkXWJdPQyS9kK/sQo3bF4OL0R/4cYhWcphayHFoQCDcCmI4IFgGQO9ZxRbSMx776EBmpX /MRDFXr6W6TiCztoU7UXGxfgsQGiTSE= X-MC-Unique: mrFf8H7uNkS7B5Ikl1564A-1 X-Mimecast-MFC-AGG-ID: mrFf8H7uNkS7B5Ikl1564A_1749485948 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749485947; x=1750090747; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E2XIrWaj9CYKaBSgFOHuJujnQV0+UP1da/Qg7ZHotwM=; b=ZhH7T1ykyDbvboivUPZnJHovMhnFrufq5tIZQxKfXpipMjwlX8Uea7Uo3OfdB+5bJu w3ME4VyTCoGBZDgCN4tZOXQOVuGUT/ryyz/dpM6srrGZ6qCcVneL2DSYMxoKLm6VR8ut Ibjb+UgnkrlXDJiRbtE6xBBuPYKxbYBXQciFBqPLk4t8AU9DymEzyXYxAYuECyLIk/C+ U2n6UzDeatzWzq8hW2rnDSpXbhS1XgSwiTN7uevawE8UtHUK5m6f66uZzwN2yDaHTSci VDd9By8dNkl6mT063MsW9k9LHIlw4C2pSI4h7w0ERVcfsOty/uSCnV9jhNAvO6cKEFYv hLSQ== X-Gm-Message-State: AOJu0YwPI+sOuUTcmSBTPEVKM4IsG4AZS83YZrIMd8i7tCA3uNuoNTl/ vtoWKLEFCwA0NBQoWZAije4ynLLbv9/rkZwT7FBUmQYoXj33dvpdAQ4iVHGAsi/kF6Q7Ni/4go0 5wvtqGm9ra9JlEpAxbIwBa1QO5Stj27ct0k3Q/vAJc515zkYliRczdpsc97jKm0olXJplyMx7H+ 6hhD3os/6kQupioeMw2WvPiAR1aJkzPcHUnYcHIA== X-Gm-Gg: ASbGncvuI7NCwWHaSLtxFMf+Jgy4oY/by0k8n4UhljlVn1/YiuQTiP7fVVMf9mZ3PbB syyAKg7G3kMk2veazCSN0Dc4pmpb5vhWkCQhh5iA2UI5DRI3+F4fBxVhOATWz2biREzzly+yf6i 24Vr3rAWuX066SeQw+DagjrULqrWQR1FbJYmz/fFygD8XMHDhTos2amasTDLtTr9cFdBp+xDJko lgtAq1y21lrGy7YLqcHOFUwh7csIXQjyQ18fole7UO9nL9FQrk4CjuZCo7DfsIvbRpjtzNOE5ky xpA= X-Received: by 2002:a05:6214:20c7:b0:6fa:ce1e:3a4a with SMTP id 6a1803df08f44-6fb08fc6ec0mr195196896d6.6.1749485947350; Mon, 09 Jun 2025 09:19:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3Li2VPoezz6Q8AEAfKnkYbp58kYo0Z7wiDWd8H64XkJPG1gTnWt2uB8ibeo/qWHffpb8ucg== X-Received: by 2002:a05:6214:20c7:b0:6fa:ce1e:3a4a with SMTP id 6a1803df08f44-6fb08fc6ec0mr195196436d6.6.1749485946943; Mon, 09 Jun 2025 09:19:06 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , peterx@redhat.com, "Dr . David Alan Gilbert" , Fabiano Rosas Subject: [PATCH v2 06/11] migration: Rename save_live_complete_precopy to save_complete Date: Mon, 9 Jun 2025 12:18:50 -0400 Message-ID: <20250609161855.6603-7-peterx@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250609161855.6603-1-peterx@redhat.com> References: <20250609161855.6603-1-peterx@redhat.com> MIME-Version: 1.0 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1749486029300116600 Content-Type: text/plain; charset="utf-8" Now after merging the precopy and postcopy version of complete() hook, rename the precopy version from save_live_complete_precopy() to save_complete(). Dropping the "live" when at it, because it's in most cases not live when happening (in precopy). No functional change intended. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas Tested-by: Mario Casquero --- include/migration/register.h | 4 ++-- hw/ppc/spapr.c | 2 +- hw/s390x/s390-stattrib.c | 2 +- hw/vfio/migration.c | 2 +- migration/block-dirty-bitmap.c | 2 +- migration/ram.c | 2 +- migration/savevm.c | 8 ++++---- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/migration/register.h b/include/migration/register.h index e022195785..0510534515 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -78,7 +78,7 @@ typedef struct SaveVMHandlers { void (*save_cleanup)(void *opaque); =20 /** - * @save_live_complete_precopy + * @save_complete * * Transmits the last section for the device containing any * remaining data at the end phase of migration. @@ -95,7 +95,7 @@ typedef struct SaveVMHandlers { * * Returns zero to indicate success and negative for error */ - int (*save_live_complete_precopy)(QEMUFile *f, void *opaque); + int (*save_complete)(QEMUFile *f, void *opaque); =20 /** * @save_live_complete_precopy_thread (invoked in a separate thread) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 702f774cda..c5d30f2ebd 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2518,7 +2518,7 @@ static void htab_save_cleanup(void *opaque) static SaveVMHandlers savevm_htab_handlers =3D { .save_setup =3D htab_save_setup, .save_live_iterate =3D htab_save_iterate, - .save_live_complete_precopy =3D htab_save_complete, + .save_complete =3D htab_save_complete, .save_cleanup =3D htab_save_cleanup, .load_state =3D htab_load, }; diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c index f74cf32636..13a678a803 100644 --- a/hw/s390x/s390-stattrib.c +++ b/hw/s390x/s390-stattrib.c @@ -338,7 +338,7 @@ static const TypeInfo qemu_s390_stattrib_info =3D { static SaveVMHandlers savevm_s390_stattrib_handlers =3D { .save_setup =3D cmma_save_setup, .save_live_iterate =3D cmma_save_iterate, - .save_live_complete_precopy =3D cmma_save_complete, + .save_complete =3D cmma_save_complete, .state_pending_exact =3D cmma_state_pending, .state_pending_estimate =3D cmma_state_pending, .save_cleanup =3D cmma_save_cleanup, diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index b76697bd1a..33a71f8999 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -824,7 +824,7 @@ static const SaveVMHandlers savevm_vfio_handlers =3D { .state_pending_exact =3D vfio_state_pending_exact, .is_active_iterate =3D vfio_is_active_iterate, .save_live_iterate =3D vfio_save_iterate, - .save_live_complete_precopy =3D vfio_save_complete_precopy, + .save_complete =3D vfio_save_complete_precopy, .save_state =3D vfio_save_state, .load_setup =3D vfio_load_setup, .load_cleanup =3D vfio_load_cleanup, diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 6ee3c32a76..a061aad817 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -1248,7 +1248,7 @@ static bool dirty_bitmap_has_postcopy(void *opaque) =20 static SaveVMHandlers savevm_dirty_bitmap_handlers =3D { .save_setup =3D dirty_bitmap_save_setup, - .save_live_complete_precopy =3D dirty_bitmap_save_complete, + .save_complete =3D dirty_bitmap_save_complete, .has_postcopy =3D dirty_bitmap_has_postcopy, .state_pending_exact =3D dirty_bitmap_state_pending, .state_pending_estimate =3D dirty_bitmap_state_pending, diff --git a/migration/ram.c b/migration/ram.c index 8b43b9e1e8..ed380ac86f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4545,7 +4545,7 @@ void postcopy_preempt_shutdown_file(MigrationState *s) static SaveVMHandlers savevm_ram_handlers =3D { .save_setup =3D ram_save_setup, .save_live_iterate =3D ram_save_iterate, - .save_live_complete_precopy =3D ram_save_complete, + .save_complete =3D ram_save_complete, .has_postcopy =3D ram_has_postcopy, .state_pending_exact =3D ram_state_pending_exact, .state_pending_estimate =3D ram_state_pending_estimate, diff --git a/migration/savevm.c b/migration/savevm.c index dfb67bf679..7dba367d33 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1496,7 +1496,7 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f) int ret; =20 QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { - if (!se->ops || !se->ops->save_live_complete_precopy) { + if (!se->ops || !se->ops->save_complete) { continue; } if (se->ops->is_active) { @@ -1509,7 +1509,7 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f) qemu_put_byte(f, QEMU_VM_SECTION_END); qemu_put_be32(f, se->section_id); =20 - ret =3D se->ops->save_live_complete_precopy(f, se->opaque); + ret =3D se->ops->save_complete(f, se->opaque); trace_savevm_section_end(se->idstr, se->section_id, ret); save_section_footer(f, se); if (ret < 0) { @@ -1583,7 +1583,7 @@ int qemu_savevm_state_complete_precopy_iterable(QEMUF= ile *f, bool in_postcopy) if (!se->ops || (in_postcopy && se->ops->has_postcopy && se->ops->has_postcopy(se->opaque)) || - !se->ops->save_live_complete_precopy) { + !se->ops->save_complete) { continue; } =20 @@ -1598,7 +1598,7 @@ int qemu_savevm_state_complete_precopy_iterable(QEMUF= ile *f, bool in_postcopy) =20 save_section_header(f, se, QEMU_VM_SECTION_END); =20 - ret =3D se->ops->save_live_complete_precopy(f, se->opaque); + ret =3D se->ops->save_complete(f, se->opaque); trace_savevm_section_end(se->idstr, se->section_id, ret); save_section_footer(f, se); if (ret < 0) { --=20 2.49.0 From nobody Sat Nov 15 16:07:34 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1749486010; cv=none; d=zohomail.com; s=zohoarc; b=PMWC+S/BmnpieKdGtWFyzu5QBfgy3VnR1ujY8tYPqqj0ttvD3YihJsVpjTIWzQ0a1wT2O70DzS42v4nlhu6PBHUvIZZ9QCwWyb24tivaUkhpySco5dExImdu1b1Fvvq14ontvPE87JC0qxkFzuqzwh8TfyGmRlYOz5+g63n7NYs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749486010; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=T6ZiNs2bgrN2dGehujOdvcshHA/0Ols9u+/LIQfENg0=; b=h3TQOTUQbs9lPFBXd5GM6U3SzsKBuiCkswbFoGwzxZjhb15ud3UYqW9jpc136ZivAK6ztUMgFS3UHgZ30Gsh0lqSnGZm5kjGBbDdKo7wHL4u+8d9tzFQY2iTZe9iZ5dimSgwXgLdMGhIs+G9SSnkP+dtKPy6VhPzA5oY/x+uPSo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1749486010284452.7874910341528; Mon, 9 Jun 2025 09:20:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOfDP-0000Ak-Sg; Mon, 09 Jun 2025 12:19:15 -0400 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 1uOfDO-00006N-3U for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uOfDM-0004Uo-49 for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:13 -0400 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-662-pqN-4fL8Or26qGWnpxHZiA-1; Mon, 09 Jun 2025 12:19:10 -0400 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6fad1f7f175so77168456d6.1 for ; Mon, 09 Jun 2025 09:19:10 -0700 (PDT) Received: from x1.local ([85.131.185.92]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6fb09ab95c1sm53420546d6.15.2025.06.09.09.19.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jun 2025 09:19:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749485951; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T6ZiNs2bgrN2dGehujOdvcshHA/0Ols9u+/LIQfENg0=; b=L0220/VRlMrT0yUOdtCDQNLpkabQxzxcN2b2A7KbXNxoXOTGGjopNVOUZwa4nh2kqGkStu DVkR/iCh4tYHSZ+nHdYu2eFrVGL9b7H/aR3Tsyii3Q/aF2/J6yWpqhPNV7Dv/gfyd0lw1J NS2MV2PefCXYkaAczbWDtWxvdAf7bvE= X-MC-Unique: pqN-4fL8Or26qGWnpxHZiA-1 X-Mimecast-MFC-AGG-ID: pqN-4fL8Or26qGWnpxHZiA_1749485950 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749485949; x=1750090749; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T6ZiNs2bgrN2dGehujOdvcshHA/0Ols9u+/LIQfENg0=; b=NNJ2SJ+qE6thFjyEcKByQDAcdkwtQ5kiKOqPwMAcK9+zHpxK5Sn3QyNErwYUb/UP1B k5pgQ8JIuta2EAUJLPnC5pMPuGCiezohHyC0ydmvtO5Sr5iEoOPXERV1wcGzzbPK/Kuk 0XnA53d/Yg38HvSAZtVWU7a1EwTeVBogSwogVEo1oZuTQqcRKEIxhQYbJFKsbuignTiX rXLA/yqQ7/eOdc1qwteJDQ+KqdYi17HvGfyalVsH3zuruhIRUfUtVg0oWWghjAoPZ+GQ awfvXcN95PVwQNXCk6tA9dMvaJSzGFN0Sa+nHlmu55ll2XsF4HS4l+nwHLm4PIWAnIcQ WlZw== X-Gm-Message-State: AOJu0YzlROJx7UP39jmFjeW0W6wOnAGdmc8f8UF+Ya/+iE79xB9uPGdd bT34+LsSHUc2d2EQMLMXDs1VU8tH/ttlwkZ23eFV3EJsDC56fO6KbXDYsALem0ubDqSSb4MMb9s EvIr/lk2DVvFAYgUAyVUWea3knZLxDYfAtFFm4kYEiYOD8hyjwZyec6vFUo/J0J91RnT68lGWlm OgS5hP1SojvDKO+LN3r/C0Vq9pVa889sWVY8kJPw== X-Gm-Gg: ASbGncv6MJueXGTkCxjQ7BEwJiFABhw6ni+/+BqX+a3JF0SE1Nv0xeDSMJoG1+sXVJX QWI3glnOZPUScAfXNPtDU4DAcfNGsHw0+Dv5Cftnq59yeg0/3VnxXjDMv4V+1Aao5Drwpmg19Yr jkZO0JdMblRz1y7NruXtrQkDMIIAzE0gKlMoTre4GWFt/lynA9uvPtsMxwdU1KTvaiLEK8HGPgt Za134IEWXZb3JCQfbfRmUADbGHFxPlvfRulKMihIhYvIFNy+IcOi4M2RBfgcOfag3/FM/we50yh Zrw= X-Received: by 2002:a05:6214:258c:b0:6fa:f59f:f349 with SMTP id 6a1803df08f44-6fb2395ffa3mr1973206d6.10.1749485949244; Mon, 09 Jun 2025 09:19:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFpRSwIUU2Efg/nXmnddzEdx3XMbZeLoql8rlEuZOZOxFK85+5nmFzXHeZieTvJnPG+JjM8tg== X-Received: by 2002:a05:6214:258c:b0:6fa:f59f:f349 with SMTP id 6a1803df08f44-6fb2395ffa3mr1972456d6.10.1749485948578; Mon, 09 Jun 2025 09:19:08 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , peterx@redhat.com, "Dr . David Alan Gilbert" , Fabiano Rosas Subject: [PATCH v2 07/11] migration: qemu_savevm_complete*() helpers Date: Mon, 9 Jun 2025 12:18:51 -0400 Message-ID: <20250609161855.6603-8-peterx@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250609161855.6603-1-peterx@redhat.com> References: <20250609161855.6603-1-peterx@redhat.com> MIME-Version: 1.0 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1749486011035116600 Content-Type: text/plain; charset="utf-8" Since we use the same save_complete() hook for both precopy and postcopy, add a set of helpers to invoke the hook() to dedup the code. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas Tested-by: Mario Casquero --- migration/savevm.c | 78 ++++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 7dba367d33..1efb7199c0 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1484,6 +1484,38 @@ bool should_send_vmdesc(void) return !machine->suppress_vmdesc; } =20 +static bool qemu_savevm_complete_exists(SaveStateEntry *se) +{ + return se->ops && se->ops->save_complete; +} + +/* + * Invoke the ->save_complete() if necessary. + * Returns: 0 if skip the current SE or succeeded, <0 if error happened. + */ +static int qemu_savevm_complete(SaveStateEntry *se, QEMUFile *f) +{ + int ret; + + if (se->ops->is_active) { + if (!se->ops->is_active(se->opaque)) { + return 0; + } + } + + trace_savevm_section_start(se->idstr, se->section_id); + save_section_header(f, se, QEMU_VM_SECTION_END); + ret =3D se->ops->save_complete(f, se->opaque); + trace_savevm_section_end(se->idstr, se->section_id, ret); + save_section_footer(f, se); + + if (ret < 0) { + qemu_file_set_error(f, ret); + } + + return ret; +} + /* * Complete saving any postcopy-able devices. * @@ -1493,27 +1525,13 @@ bool should_send_vmdesc(void) void qemu_savevm_state_complete_postcopy(QEMUFile *f) { SaveStateEntry *se; - int ret; =20 QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { - if (!se->ops || !se->ops->save_complete) { + if (!qemu_savevm_complete_exists(se)) { continue; } - if (se->ops->is_active) { - if (!se->ops->is_active(se->opaque)) { - continue; - } - } - trace_savevm_section_start(se->idstr, se->section_id); - /* Section type */ - qemu_put_byte(f, QEMU_VM_SECTION_END); - qemu_put_be32(f, se->section_id); =20 - ret =3D se->ops->save_complete(f, se->opaque); - trace_savevm_section_end(se->idstr, se->section_id, ret); - save_section_footer(f, se); - if (ret < 0) { - qemu_file_set_error(f, ret); + if (qemu_savevm_complete(se, f) < 0) { return; } } @@ -1559,7 +1577,6 @@ int qemu_savevm_state_complete_precopy_iterable(QEMUF= ile *f, bool in_postcopy) { int64_t start_ts_each, end_ts_each; SaveStateEntry *se; - int ret; bool multifd_device_state =3D multifd_device_state_supported(); =20 if (multifd_device_state) { @@ -1580,32 +1597,25 @@ int qemu_savevm_state_complete_precopy_iterable(QEM= UFile *f, bool in_postcopy) } =20 QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { - if (!se->ops || - (in_postcopy && se->ops->has_postcopy && - se->ops->has_postcopy(se->opaque)) || - !se->ops->save_complete) { + if (!qemu_savevm_complete_exists(se)) { continue; } =20 - if (se->ops->is_active) { - if (!se->ops->is_active(se->opaque)) { - continue; - } + if (in_postcopy && se->ops->has_postcopy && + se->ops->has_postcopy(se->opaque)) { + /* + * If postcopy will start soon, and if the SE supports + * postcopy, then we can skip the SE for the postcopy phase. + */ + continue; } =20 start_ts_each =3D qemu_clock_get_us(QEMU_CLOCK_REALTIME); - trace_savevm_section_start(se->idstr, se->section_id); - - save_section_header(f, se, QEMU_VM_SECTION_END); - - ret =3D se->ops->save_complete(f, se->opaque); - trace_savevm_section_end(se->idstr, se->section_id, ret); - save_section_footer(f, se); - if (ret < 0) { - qemu_file_set_error(f, ret); + if (qemu_savevm_complete(se, f) < 0) { goto ret_fail_abort_threads; } end_ts_each =3D qemu_clock_get_us(QEMU_CLOCK_REALTIME); + trace_vmstate_downtime_save("iterable", se->idstr, se->instance_id, end_ts_each - start_ts_each); } --=20 2.49.0 From nobody Sat Nov 15 16:07:34 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1749486016; cv=none; d=zohomail.com; s=zohoarc; b=ZbZxonyKf2DnDt8TVliowEmvrq3w/RjBVFxaw2pxAvY+I4cXjzMo8AnPfJexr9QU4O0OPDVqKpJ3k+LPQLFzDQ/K7i4ns2G5v4fcuohwnuZAVLEEQxC14lMsQjOPFO+5TVhKh77gM+68ClQqEoCLJlNW199iU7E3rVHxWByFVS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749486016; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0gBjc7m16rQwKWYyV/3t//9MlDB/n3QsWgc67i1f8wg=; b=E2JtOuY6WcYsYvKZ/QqCmoxEQ9cjmon5AAPX8CBgZ2/x6LK1e0ixoGsT6E/jXomIzxsgAdUyRLGQRZwWHG4AQvrkwuBlgSl5aPa4mBb0SLfxhKA/R0pNAl0+BBOy4imCyXQA78vtOpsJiNXkpX7Oq2ThzYRCGOLCpZionaAeF5c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1749486016186737.3798374266265; Mon, 9 Jun 2025 09:20:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOfDb-0000Yq-5l; Mon, 09 Jun 2025 12:19:27 -0400 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 1uOfDZ-0000Xr-5E for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uOfDS-0004Vt-2K for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:24 -0400 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-630-SZkohqQKPgy8BwyZrae3Ng-1; Mon, 09 Jun 2025 12:19:11 -0400 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6fafb2f0a33so68835986d6.0 for ; Mon, 09 Jun 2025 09:19:11 -0700 (PDT) Received: from x1.local ([85.131.185.92]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6fb09ab95c1sm53420546d6.15.2025.06.09.09.19.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jun 2025 09:19:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749485957; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0gBjc7m16rQwKWYyV/3t//9MlDB/n3QsWgc67i1f8wg=; b=DS4hoQDR7zFbYdxigv5w/qKLDKLf/ki5p0elC284IKi+87iGjIYo5Bl8QRrP2asACfMHLq ZWcru46bhowzUwSvHTllusSx7bOn699BXzaElB6RLy5lVLuZqPnxY1WURE2atzhlMS5CEi ayN/MRHVSzlZwHO5sGCztfXVkGEmc1s= X-MC-Unique: SZkohqQKPgy8BwyZrae3Ng-1 X-Mimecast-MFC-AGG-ID: SZkohqQKPgy8BwyZrae3Ng_1749485950 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749485950; x=1750090750; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0gBjc7m16rQwKWYyV/3t//9MlDB/n3QsWgc67i1f8wg=; b=ARtEdp6uTAQZdo43CsnOcBUo/PumWy/u34IkT03nN6KlE7vsam8loIZlZH1WvCtdEh JFc/5DBqZSdXeBPQ6f88nYrfPP54jNTIf/Ib4Vl3Eq5TfwJ43uSA212esI5z+BN80YVY wq4wFSNjXY/VudRSfvDeymzk/mX9Ap9y0XH2quC4FAgOzE7W1nO1nU9XDxt3zkdt44xn 51MgFGQbeG09R3tbNjhSopDCabsXUkIZ5J+cuF/Ai2CNIB+YclDJvDWppejxJ5rpHavq OM71VV5C0NNZgUKRuqYMoUE9N2DJYnBTRVZVdh//mceAul1Q2wqZ96oaccKYzUjeuMmN Yjzg== X-Gm-Message-State: AOJu0Yzc2xId8nd6ld6puIaZxFVw2n1MgoWm4MS+iYOcQqJLbzxcEGOh SPBFULh4iLFgyo6RymRmZyZVVRjYHURK6Vh7221No2AxyFsAsgYr/eVntL+wik+j5FQ/eskxD5C x2tEuR+qHQnFTNrTCPUZ4L3fi7Uf/2mh+JbMxzph76eHnt23uUaTanHSt/Egt/gTTZsTJyyHAAf UCb7ATu3HrQ8wUtu+I7pbYFu1n1j3fPHWIEM8GLg== X-Gm-Gg: ASbGncv2vHK/KphOQeDifQAu5lC0wh4v7ciHCNdo4f1DJhTgy6H6Xoy/s6JERMsZL0g A7I/b47vau/FXaWHdL7YPhvQtQKzBINqNYXixkeUWf+VIDpoqIy/R+hzkHbeFr3ubohd5HrX0sM tADMNAHnj6Du1CKDrZHwdWBosTRzA1OArdvMREO55889VWNVogrI4LACD4Nq/x+SB+DiYXJz6iq 40LwgN1Do9Soc97T0ucvTMtmbxCPgoO0YxsZSOy9LcFdlOl0xgK3lhl2/aW65t9Z2AfBXQwsh/B HtU+NTMz0IC08g== X-Received: by 2002:a05:6214:518f:b0:6f8:b4aa:2a4b with SMTP id 6a1803df08f44-6fb08fbb540mr235601096d6.28.1749485950156; Mon, 09 Jun 2025 09:19:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+JhK2D+zRr0c/sToY/ET/YTchuQuXkch4HwDCvB3BqTZlY0Ak2NSVjJqvEf+pZscQeAF6OA== X-Received: by 2002:a05:6214:518f:b0:6f8:b4aa:2a4b with SMTP id 6a1803df08f44-6fb08fbb540mr235600506d6.28.1749485949666; Mon, 09 Jun 2025 09:19:09 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , peterx@redhat.com, "Dr . David Alan Gilbert" , Fabiano Rosas Subject: [PATCH v2 08/11] migration/ram: One less indent for ram_find_and_save_block() Date: Mon, 9 Jun 2025 12:18:52 -0400 Message-ID: <20250609161855.6603-9-peterx@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250609161855.6603-1-peterx@redhat.com> References: <20250609161855.6603-1-peterx@redhat.com> MIME-Version: 1.0 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1749486017024116600 Content-Type: text/plain; charset="utf-8" The check over PAGE_DIRTY_FOUND isn't necessary. We could indent one less and assert that instead. Reviewed-by: Juraj Marcin Signed-off-by: Peter Xu Tested-by: Mario Casquero --- migration/ram.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index ed380ac86f..c66ad3cf8b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2285,16 +2285,18 @@ static int ram_find_and_save_block(RAMState *rs) if (!get_queued_page(rs, pss)) { /* priority queue empty, so just search for something dirty */ int res =3D find_dirty_block(rs, pss); - if (res !=3D PAGE_DIRTY_FOUND) { - if (res =3D=3D PAGE_ALL_CLEAN) { - break; - } else if (res =3D=3D PAGE_TRY_AGAIN) { - continue; - } else if (res < 0) { - pages =3D res; - break; - } + + if (res =3D=3D PAGE_ALL_CLEAN) { + break; + } else if (res =3D=3D PAGE_TRY_AGAIN) { + continue; + } else if (res < 0) { + pages =3D res; + break; } + + /* Otherwise we must have a dirty page to move */ + assert(res =3D=3D PAGE_DIRTY_FOUND); } pages =3D ram_save_host_page(rs, pss); if (pages) { --=20 2.49.0 From nobody Sat Nov 15 16:07:34 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1749485975; cv=none; d=zohomail.com; s=zohoarc; b=EZxB2ZzeTMvGBNHG+MY9+6Ev3xBM/zBK1dJCoY8OWlhwGsTB7O2OFX0RKJ9ebJ43O8pNbILEJDH4geESTlMS2s08UE7Vn9bs03XPpGfLJYB2lPLgXpe7owcxf/dMdv6LYUotfVKEx/vZ+1rdSHFQyxCqLRFtz4+zujmxPLqnXik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749485975; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1A0fDBuQYTqmVarAzgYqBRrK/hWUHvpepmptSmGtWkw=; b=ZguiN/sFxLEDc7W1t//i1vJ322X0/OGztSQwO9OtA1u8UzwthEVBtmb/Z9V1EkmURtdJNzP2mPDvtHZAdQ7G75somcoaHHe2yK7TatArZ0zGOcXBA6MkCURgvEfVxEMLRJxkD/X20qL/YLHbsiRAeP0Er3YABT/ox2wtGnf3lgk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1749485975522910.2041119697502; Mon, 9 Jun 2025 09:19:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOfDS-0000HV-J8; Mon, 09 Jun 2025 12:19:18 -0400 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 1uOfDQ-0000Em-Ou for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uOfDP-0004VO-1t for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:16 -0400 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-479-FXd27-CgNzuq5zHHzD7Dlw-1; Mon, 09 Jun 2025 12:19:12 -0400 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6fab979413fso93703016d6.2 for ; Mon, 09 Jun 2025 09:19:12 -0700 (PDT) Received: from x1.local ([85.131.185.92]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6fb09ab95c1sm53420546d6.15.2025.06.09.09.19.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jun 2025 09:19:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749485954; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1A0fDBuQYTqmVarAzgYqBRrK/hWUHvpepmptSmGtWkw=; b=gQ24j8dPjQ+o8Wu2g36WpLVJEXIxJ+47FPdXjIp58rpECorqF21x+p52GCP5q5Gh1EXwQj 0ykLr/fOCly8T8lc4pZT5ZC1YK5mfGSGEczTMkJj2jJaY6aImtfT+ekRSNvGoiHit1HClq Db98qLzYyJHE3CW9dof0Ex2kub1wYSA= X-MC-Unique: FXd27-CgNzuq5zHHzD7Dlw-1 X-Mimecast-MFC-AGG-ID: FXd27-CgNzuq5zHHzD7Dlw_1749485952 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749485952; x=1750090752; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1A0fDBuQYTqmVarAzgYqBRrK/hWUHvpepmptSmGtWkw=; b=jadkWs++V0798wPVcsxQpNo+LRtGFBPIgrA8y7tVukvzKsUultt8qTlfECVkopeBMG MEkjaZ38GSYLz9GdMdLaJoNyQFPaxg+XCqk0AqeQ3p1rwCtPn0fHLuXdA6c0etxlH9jE fV+/ohSCCRzFPq7n7yJiq8aYDhKcqdc0HA6zZK1RJQRbHgpeTMzCZWRoTKrljl6di50M xkIjk2QJVttMc5zC3Ge0PxXpQNDkvJoJhf5+vI+jno5ZUhIAIOnP8JYPygliXpLEk5Bk qNWUr5NPBICgHJLDaD2oIQzq6TPmK9a5FDTBwFNZKpfMibgniCYkRfum+F3ZQ/XmkFuB WRVQ== X-Gm-Message-State: AOJu0Yz4JUiEs2eSR0z/STRKLI5WBhUJWfTOQZf7hL/wM25wYG6Vx3Ao 3Cox2wqpvOElbbIPGHFM3ki6k62ZU5/WnU0c/XEkVb1NBnqeJYp56pq/D1YhyUXqzX4lznhvvZn 2pcPqSKhBPtjU+fxICQ0D5osVLX37zHXPzuL5nHIYYDSBgg39s5Q7Cczd5b4NZ9GK6PFxj18QDG G65QMyskvtD6nEFFd09IsaquBOTTp1+qAaicF1Nw== X-Gm-Gg: ASbGnctMVdiSJCLCzBRLiyQZT1/aaOXn/x9A81ssVtKZPDZHYDzUFe+jSLN17n84CLM 7GqDw5WjtnoXBl4RcyIOmPT6PogNJpiiBC66yO0fRh/4muiXxg8eY3sybNErh5GarqwwE0y/TT7 MriECX5SOF3poTO0nBPjKpb40jFXceZiKcWbIxYvhJMMdc93M9NEx0eJ7RHiUgODk+NB1MdPUq3 L/xybA8oj/ia2J6jzQuXQMiv4RrvlNKq/FT57fm3689q081eDmLopge/Swk6WWqSL20aHYw9EFB I/M4sVrRyZmZ+Q== X-Received: by 2002:ad4:5ec8:0:b0:6fa:c512:c401 with SMTP id 6a1803df08f44-6fb08f8e1e8mr255297036d6.37.1749485951746; Mon, 09 Jun 2025 09:19:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGriEh2EYiJScSOlXvurREi+eVsRbz+hZ0TRwyl7GH4ptlWVx+ibukSColv2nP0/p4AbwU32Q== X-Received: by 2002:ad4:5ec8:0:b0:6fa:c512:c401 with SMTP id 6a1803df08f44-6fb08f8e1e8mr255296406d6.37.1749485951176; Mon, 09 Jun 2025 09:19:11 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , peterx@redhat.com, "Dr . David Alan Gilbert" , Fabiano Rosas Subject: [PATCH v2 09/11] migration/ram: Add tracepoints for ram_save_complete() Date: Mon, 9 Jun 2025 12:18:53 -0400 Message-ID: <20250609161855.6603-10-peterx@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250609161855.6603-1-peterx@redhat.com> References: <20250609161855.6603-1-peterx@redhat.com> MIME-Version: 1.0 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1749485976489116600 Content-Type: text/plain; charset="utf-8" Take notes on start/end state of dirty pages for the whole system. Reviewed-by: Juraj Marcin Signed-off-by: Peter Xu Tested-by: Mario Casquero --- migration/ram.c | 5 +++++ migration/trace-events | 1 + 2 files changed, 6 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index c66ad3cf8b..a1d0e8ada2 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3289,6 +3289,8 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) RAMState *rs =3D *temp; int ret =3D 0; =20 + trace_ram_save_complete(rs->migration_dirty_pages, 0); + rs->last_stage =3D !migration_in_colo_state(); =20 WITH_RCU_READ_LOCK_GUARD() { @@ -3352,6 +3354,9 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) } =20 qemu_put_be64(f, RAM_SAVE_FLAG_EOS); + + trace_ram_save_complete(rs->migration_dirty_pages, 1); + return qemu_fflush(f); } =20 diff --git a/migration/trace-events b/migration/trace-events index c506e11a2e..dcd8fe9a0c 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -105,6 +105,7 @@ ram_load_postcopy_loop(int channel, uint64_t addr, int = flags) "chan=3D%d addr=3D0x%" ram_postcopy_send_discard_bitmap(void) "" ram_save_page(const char *rbname, uint64_t offset, void *host) "%s: offset= : 0x%" PRIx64 " host: %p" ram_save_queue_pages(const char *rbname, size_t start, size_t len) "%s: st= art: 0x%zx len: 0x%zx" +ram_save_complete(uint64_t dirty_pages, int done) "dirty=3D%" PRIu64 ", do= ne=3D%d" ram_dirty_bitmap_request(char *str) "%s" ram_dirty_bitmap_reload_begin(char *str) "%s" ram_dirty_bitmap_reload_complete(char *str) "%s" --=20 2.49.0 From nobody Sat Nov 15 16:07:34 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1749486029; cv=none; d=zohomail.com; s=zohoarc; b=Cc3uSSF/vMdlRwkz3uylZzGj9t8hd+VDgRDqhOcmtF5ty9QrFk+drPJPibFEY/3lamg6y+AUqOpuakPRKo2i3kuIyQHGa/EsbyFbjVATUNJWyYLbYXQftqxFy+/JHg76BKNhhesRjq+0bsx75ta7o55YGByWvf4gMhkb+90EqC4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749486029; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+tgiVBDvopoht8yBW2Hx5L1ZBKRLyR84q/WVPp5DRwQ=; b=Cynfq4KGx/kH08ZVCdyx/+b/9b2Rs3Bn0hnQ1rpVYdjYXI3tqPCTsYrJdDgaEGhi0FVkYHpu30oypRzMcLJ9MGTxvhjY4VEj7WTiqlC5NOHhGQ+8DArCCy5wTCTXqj+VTL+8w6XZYM6JpAJUJGY7k5aGkkArJuWk/ZPXQlK7r4A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1749486029373778.6288524133188; Mon, 9 Jun 2025 09:20:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOfEC-00014p-S8; Mon, 09 Jun 2025 12:20:05 -0400 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 1uOfDo-0000me-R3 for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uOfDm-0004Xd-GB for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:40 -0400 Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-620-4GLsOqpJPVqAviSdVGbEnA-1; Mon, 09 Jun 2025 12:19:36 -0400 Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-31218e2d5b0so6612744a91.2 for ; Mon, 09 Jun 2025 09:19:36 -0700 (PDT) Received: from x1.local ([85.131.185.92]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6fb09ab95c1sm53420546d6.15.2025.06.09.09.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jun 2025 09:19:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749485977; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+tgiVBDvopoht8yBW2Hx5L1ZBKRLyR84q/WVPp5DRwQ=; b=A0BZjc3TINdzSsARY2J9/1Xdg3+t4sR6AFOGD/zsD1HtaOux58VUzWkZBUwZQsBj2/5Upf OFLjaAgBtceltpRwzgPfwlgCua3/XUu4VzYT82LUiLfVRiCNR/b8Fr6dWTOf2iJv5mAxEz ql8tCnQXIViZMgH834f/px0hUPJQCkg= X-MC-Unique: 4GLsOqpJPVqAviSdVGbEnA-1 X-Mimecast-MFC-AGG-ID: 4GLsOqpJPVqAviSdVGbEnA_1749485976 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749485975; x=1750090775; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+tgiVBDvopoht8yBW2Hx5L1ZBKRLyR84q/WVPp5DRwQ=; b=wKPW4DQxovZihtGwo6TlKXj5Kj8pizLncMTN5JIDSvytezGg0SxfxtBxEW2jWD6NOs Jzh7SxD4zUw4XRR4rHb4d0RQR8iX2PzwaoR0qw8p5psWVrHvOfwEuZlT5XroqobQMfpW jeyQDEGxzGghDuAMhYYsmDYkVHUbABKobcEzjxMJXHo+gtdA3AjKlnIcXmsL8F6K78fm VMrm1d1CejSwTRf51LZuYoJBOyo48gNra5djQRW9vcfBd2NYSxWWuWpJgKalkZXWm6Jz l7FEsqLZ8FJDoU/mG/slaDuZLkU3OHy1vEkpdBJOhz7nYLK5b9lmzXe3/2o/Sv71Yz9t +OIw== X-Gm-Message-State: AOJu0Yz9HS0uyoq7scxXlgNBWDRkPCLcCQwWNg3qLQpAPpM2IR/M2mqv I5ZSGdOQhPFyml6XXpM/Z+tFlDEVhztDoPR1srkWaQc7PVQSTtEeDmDyYq+jKAe3YWnuY2e/n5x 0BWaqXnzUJGk9QnTqToA5dMWALdZWBMOc8YkzvHF6wY5enHCFO6O4+Fmk6lf+dVj+lehFa84/SF oONFgrHuJbZrYDuUwo65bsP9Gq/NiCiWtB9wkfvg== X-Gm-Gg: ASbGncsMct1jD5bwQ5St/+am5AmPekGZrl8p01pMNoy/qmk+neZQ5JGHR9EmBLsbpfx 7vdoH+sEioRtGg3UtRF9wh/wiW7S5gFiaaGncqU7iw6esJfKhr5xba66uCHMeZPAMzo5/USpMA5 BMvM5iskb/cb2PFnZnb8CuvWiIp4XP+5yMYMoTtCUra7bUlDkeuBM/j+Gpd0LZosKh/fl3utkAx z6m/RfEImRancF7G78TEZ2fJtqBkHlSA62XbX1MGx7A5oBxI+WKpXpZdWlh2Tu4K/Ln01xCfLNA VbY= X-Received: by 2002:ad4:5b8f:0:b0:6fa:c634:dc01 with SMTP id 6a1803df08f44-6fb08f78beamr245544716d6.16.1749485964558; Mon, 09 Jun 2025 09:19:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH84b24kYpwH0Sm4PXEe56IVnjhbSnvBe1JkUQyzp59RNmkh6ntSVVw70R0QzitjXRZmR49+w== X-Received: by 2002:a05:6214:b6b:b0:6fa:b42b:2bd9 with SMTP id 6a1803df08f44-6fb08fe37eamr253861546d6.37.1749485952825; Mon, 09 Jun 2025 09:19:12 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , peterx@redhat.com, "Dr . David Alan Gilbert" , Fabiano Rosas Subject: [PATCH v2 10/11] migration: Rewrite the migration complete detect logic Date: Mon, 9 Jun 2025 12:18:54 -0400 Message-ID: <20250609161855.6603-11-peterx@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250609161855.6603-1-peterx@redhat.com> References: <20250609161855.6603-1-peterx@redhat.com> MIME-Version: 1.0 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1749486031303116600 Content-Type: text/plain; charset="utf-8" There're a few things off here in that logic, rewrite it. When at it, add rich comment to explain each of the decisions. Since this is very sensitive path for migration, below are the list of things changed with their reasonings. (1) Exact pending size is only needed for precopy not postcopy Fundamentally it's because "exact" version only does one more deep sync to fetch the pending results, while in postcopy's case it's never going to sync anything more than estimate as the VM on source is stopped. (2) Do _not_ rely on threshold_size anymore to decide whether postcopy should complete threshold_size was calculated from the expected downtime and bandwidth only during precopy as an efficient way to decide when to switchover. It's not sensible to rely on threshold_size in postcopy. For precopy, if switchover is decided, the migration will complete soon. It's not true for postcopy. Logically speaking, postcopy should only complete the migration if all pending data is flushed. Here it used to work because save_complete() used to implicitly contain save_live_iterate() when there's pending size. Even if that looks benign, having RAMs to be migrated in postcopy's save_complete() has other bad side effects: (a) Since save_complete() needs to be run once at a time, it means when moving RAM there's no way moving other things (rather than round-robin iterating the vmstate handlers like what we do with ITERABLE phase). Not an immediate concern, but it may stop working in the future when there're more than one iterables (e.g. vfio postcopy). (b) postcopy recovery, unfortunately, only works during ITERABLE phase. IOW, if src QEMU moves RAM during postcopy's save_complete() and network failed, then it'll crash both QEMUs... OTOH if it failed during iteration it'll still be recoverable. IOW, this change should further reduce the window QEMU split brain and crash in extreme cases. If we enable the ram_save_complete() tracepoints, we'll see this before this patch: 1267959@1748381938.294066:ram_save_complete dirty=3D9627, done=3D0 1267959@1748381938.308884:ram_save_complete dirty=3D0, done=3D1 It means in this migration there're 9627 pages migrated at complete() of postcopy phase. After this change, all the postcopy RAM should be migrated in iterable phase, rather than save_complete(): 1267959@1748381938.294066:ram_save_complete dirty=3D0, done=3D0 1267959@1748381938.308884:ram_save_complete dirty=3D0, done=3D1 (3) Adjust when to decide to switch to postcopy This shouldn't be super important, the movement makes sure there's only one in_postcopy check, then we are clear on what we do with the two completely differnt use cases (precopy v.s. postcopy). (4) Trivial touch up on threshold_size comparision Which changes: "(!pending_size || pending_size < s->threshold_size)" into: "(pending_size <=3D s->threshold_size)" Reviewed-by: Juraj Marcin Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas Tested-by: Mario Casquero --- migration/migration.c | 56 +++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index e33e39ac74..1a26a4bfef 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3436,33 +3436,59 @@ static MigIterateState migration_iteration_run(Migr= ationState *s) Error *local_err =3D NULL; bool in_postcopy =3D s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE; bool can_switchover =3D migration_can_switchover(s); + bool complete_ready; =20 + /* Fast path - get the estimated amount of pending data */ qemu_savevm_state_pending_estimate(&must_precopy, &can_postcopy); pending_size =3D must_precopy + can_postcopy; trace_migrate_pending_estimate(pending_size, must_precopy, can_postcop= y); =20 - if (pending_size < s->threshold_size) { - qemu_savevm_state_pending_exact(&must_precopy, &can_postcopy); - pending_size =3D must_precopy + can_postcopy; - trace_migrate_pending_exact(pending_size, must_precopy, can_postco= py); + if (in_postcopy) { + /* + * Iterate in postcopy until all pending data flushed. Note that + * postcopy completion doesn't rely on can_switchover, because when + * POSTCOPY_ACTIVE it means switchover already happened. + */ + complete_ready =3D !pending_size; + } else { + /* + * Exact pending reporting is only needed for precopy. Taking RAM + * as example, there'll be no extra dirty information after + * postcopy started, so ESTIMATE should always match with EXACT + * during postcopy phase. + */ + if (pending_size < s->threshold_size) { + qemu_savevm_state_pending_exact(&must_precopy, &can_postcopy); + pending_size =3D must_precopy + can_postcopy; + trace_migrate_pending_exact(pending_size, must_precopy, can_po= stcopy); + } + + /* Should we switch to postcopy now? */ + if (must_precopy <=3D s->threshold_size && + can_switchover && qatomic_read(&s->start_postcopy)) { + if (postcopy_start(s, &local_err)) { + migrate_set_error(s, local_err); + error_report_err(local_err); + } + return MIG_ITERATE_SKIP; + } + + /* + * For precopy, migration can complete only if: + * + * (1) Switchover is acknowledged by destination + * (2) Pending size is no more than the threshold specified + * (which was calculated from expected downtime) + */ + complete_ready =3D can_switchover && (pending_size <=3D s->thresho= ld_size); } =20 - if ((!pending_size || pending_size < s->threshold_size) && can_switcho= ver) { + if (complete_ready) { trace_migration_thread_low_pending(pending_size); migration_completion(s); return MIG_ITERATE_BREAK; } =20 - /* Still a significant amount to transfer */ - if (!in_postcopy && must_precopy <=3D s->threshold_size && can_switcho= ver && - qatomic_read(&s->start_postcopy)) { - if (postcopy_start(s, &local_err)) { - migrate_set_error(s, local_err); - error_report_err(local_err); - } - return MIG_ITERATE_SKIP; - } - /* Just another iteration step */ qemu_savevm_state_iterate(s->to_dst_file, in_postcopy); return MIG_ITERATE_RESUME; --=20 2.49.0 From nobody Sat Nov 15 16:07:34 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1749486005; cv=none; d=zohomail.com; s=zohoarc; b=WbOhKulcrK5fjSkFI+23LPm8KENK4zQCh6lnr31Qos3giOw6RwiF7nEG9cFCITeBBvkFw2kAwXN/O1NQbexv0lODI4efVj7s/ENiiZRMX31ch/Mtj59oKq4W7Ph30F7zFuW49mJwCthMxFSCQ1dx/VsUxM9hXVwi27+4dzJPxnw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749486005; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=81vpRbPBsl4TxnkuqSVUCogqP7kEXR/iTLHp+dsYNmM=; b=PezOj4exwgotKhf/BQLzLxoilMhaJGv9FFxpFAjHMAhrKCJD5mtaOZSGPCI+irg0uE5J6aMpefQTJp4GAEtqOfW3x48AY8XTgcFdydkpWl7rCXo9pyKtw0KwB7O3RxX1/wYKiUkV6jM/jkYUPoL+vnoSu+268Aum0imJzTN8MTo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1749486005198443.1748203800554; Mon, 9 Jun 2025 09:20:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOfDU-0000O8-S2; Mon, 09 Jun 2025 12:19:20 -0400 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 1uOfDS-0000Jw-OY for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uOfDQ-0004VY-V2 for qemu-devel@nongnu.org; Mon, 09 Jun 2025 12:19:18 -0400 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-610-WrAZOdTUOQ6xog6OK0mAqA-1; Mon, 09 Jun 2025 12:19:15 -0400 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6faca0f2677so127365306d6.1 for ; Mon, 09 Jun 2025 09:19:15 -0700 (PDT) Received: from x1.local ([85.131.185.92]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6fb09ab95c1sm53420546d6.15.2025.06.09.09.19.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jun 2025 09:19:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749485956; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=81vpRbPBsl4TxnkuqSVUCogqP7kEXR/iTLHp+dsYNmM=; b=YhEGNd17w2Q4O8WnFbsgkG0KR6VJI7qrv5x+hPsqcXxutwSz9TVjf9vvG3cQJvb9T3v6Hz eI0ABkZao/dBQnHYtoTgXaFQHDzE8a+ak6Aq3tQCxp8/QaqujhdM9Vqhrgq3xXhd2XivLy +DPikUMQaqZLdXAOz+hPbpi+OCmxifE= X-MC-Unique: WrAZOdTUOQ6xog6OK0mAqA-1 X-Mimecast-MFC-AGG-ID: WrAZOdTUOQ6xog6OK0mAqA_1749485955 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749485954; x=1750090754; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=81vpRbPBsl4TxnkuqSVUCogqP7kEXR/iTLHp+dsYNmM=; b=Pgz8BaZVufntzZ4voVjUWDvf2oxkIPHWel5Vb7yQwvTbejLLvw4+WAl2XZiH8StLFT RIJHGUDdOATy+HDmIvzR4H4L/zZfqxq37dUJpKYSzOEtmPY53gpfi2bFfRLlopI5HqsE fISxnNPno71F+crRsFP2UmDN/T0fpVm16xnsg9a1xHoU+ujPwEQHlskWPPg9xUIZKqRX m8jEsRT5MGVoHwIii3W3IwgZlnLT4ST5ctHTzqYeom9GA0/U2ORldjLC6YETtk7ZX5vj +PPJTKuCkB3AFqmVCKkQdlt7Vwuf0Wpg6MIiYcKGo2NErOIYpB0rXhB6MeM128d8Ub12 fnEw== X-Gm-Message-State: AOJu0Yw8T9F+9s8/7O3QTfwgpg9yKyEyETWWnVXbWau4Rd/mgtyRAH9a WFru/t5zwyYJl6cOsCkONntLdyktiTgQbzTrE8IGFYCnwjdrZmEh5ZA+wWgLrfSe1gtb0L6qUU+ LXGZSttivXQkVi9WwKqqfHWW17W4YmlQGuUJOR9CvuLesfWr6GGBoPEF/g2cVenoymGEll87zNd E9CXo1sAfi8p1l/qH1/uXKPyzvAEajtI2Tu9+kwA== X-Gm-Gg: ASbGncunbd5SlcNT/rWoIA61qV1BrNvBdozoIpOWwsie0X3HuSmu6h9zD69iVLr5fRU mVFthWoIVA900AL18b6dcMYGWJUqsSY1wLB6m4bX6k5F/6f0XC2K/ha9qlNOsfWCNUqFDVLNvIF WqPCN34VcbwnwS/+N8SVL8iWn8UNMUbD9bgRP1XuLE6zVUnDCpBEdWQCkNnGGnSfUnvb2JnxltI eBUOtYv6hOmZmZGFdLpe8YMnZr4EHMMhfHV54h1e9oMWHhfgLpzIAZY4h7t1i6C3A5/X3KUX5ox NV4= X-Received: by 2002:a05:6214:528d:b0:6fa:bab1:f797 with SMTP id 6a1803df08f44-6fb08fe4c73mr220722506d6.10.1749485954447; Mon, 09 Jun 2025 09:19:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGZErq1RkJKPnlNKJLCLF5JDlQ1gErGbxsBDnSZAz9cCLB4pVASt1u/61YVXtUWWCw0j8lZhw== X-Received: by 2002:a05:6214:528d:b0:6fa:bab1:f797 with SMTP id 6a1803df08f44-6fb08fe4c73mr220722006d6.10.1749485953970; Mon, 09 Jun 2025 09:19:13 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , peterx@redhat.com, "Dr . David Alan Gilbert" , Fabiano Rosas , Yanfei Xu Subject: [PATCH v2 11/11] migration/postcopy: Avoid clearing dirty bitmap for postcopy too Date: Mon, 9 Jun 2025 12:18:55 -0400 Message-ID: <20250609161855.6603-12-peterx@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250609161855.6603-1-peterx@redhat.com> References: <20250609161855.6603-1-peterx@redhat.com> MIME-Version: 1.0 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1749486006882116600 Content-Type: text/plain; charset="utf-8" This is a follow up on the other commit "migration/ram: avoid to do log clear in the last round" but for postcopy. https://lore.kernel.org/r/20250514115827.3216082-1-yanfei.xu@bytedance.com I can observe more than 10% reduction of average page fault latency during postcopy phase with this optimization: Before: 268.00us (+-1.87%) After: 232.67us (+-2.01%) The test was done with a 16GB VM with 80 vCPUs, running a workload that busy random writes to 13GB memory. Cc: Yanfei Xu Reviewed-by: Fabiano Rosas Signed-off-by: Peter Xu Tested-by: Mario Casquero --- migration/ram.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/migration/ram.c b/migration/ram.c index a1d0e8ada2..cd4aafd15c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -835,8 +835,10 @@ static inline bool migration_bitmap_clear_dirty(RAMSta= te *rs, * protections isn't needed as we know there will be either (1) no * further writes if migration will complete, or (2) migration fails * at last then tracking isn't needed either. + * + * Do the same for postcopy due to the same reason. */ - if (!rs->last_stage) { + if (!rs->last_stage && !migration_in_postcopy()) { /* * Clear dirty bitmap if needed. This _must_ be called before we * send any of the page in the chunk because we need to make sure --=20 2.49.0