From nobody Sun Mar 22 15:40:01 2026 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=1773962101; cv=none; d=zohomail.com; s=zohoarc; b=DJD7VwJyXOSK9T6YzWkoICoS467X9bWvuQhI7PjubJL9u44xe4SrX4xDeF6WslhUIjlypTZlJFFw/S5QSqsVfyRiBhSX6M71R59Kp7horXzGDvUJReaUt6Ttc+5m/CLoT3YEAoE/UewEP7Gihy4AhdNn6KoltF47Qx/r00DPyLQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773962101; 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=6RAHkTnj5upfaZ8SooBURZ2Qif/9bxeVdrP7OGRyeXk=; b=D6yIsH2Y0us9Vwk1xoKILz/Zg5LErnm5QCNp61LdxrdC8V9n748ZztJZx/qKYKpOv9DKALHb7LBLuMEZhCa7xUT0GkoNsE1dv2HFRJ0PvPAnO6wX2ufeUOYDtiQEPBilkq8vFusaydcy0aSreCjqfXSY6wis9urNFucfRAVI2Yg= 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 1773962101591598.5606968541306; Thu, 19 Mar 2026 16:15:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w3MYa-0001Qg-Ad; Thu, 19 Mar 2026 19:13:36 -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 1w3MYZ-0001QT-LC for qemu-devel@nongnu.org; Thu, 19 Mar 2026 19:13:35 -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 1w3MYY-0001cN-4N for qemu-devel@nongnu.org; Thu, 19 Mar 2026 19:13:35 -0400 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-411-rgZjUUthOei7N9FZm9bKGA-1; Thu, 19 Mar 2026 19:13:32 -0400 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-50937cf66b5so6337291cf.3 for ; Thu, 19 Mar 2026 16:13:32 -0700 (PDT) Received: from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50b36e5bee3sm6717161cf.21.2026.03.19.16.13.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Mar 2026 16:13:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773962013; 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=6RAHkTnj5upfaZ8SooBURZ2Qif/9bxeVdrP7OGRyeXk=; b=cV7iY6gBJWI64XcB9BhExjZ3Nktsm+SkDSkpqH+GBGW3CwDKi5eyV2VFVzTFZMUVYa/+Tb eEBtFwdDaz35urIzokdolN/yBc90UER6oIKR35ENR/Uo7uXNur3yI/sE0B+F6lr4Pl/rXz BYIbdYaMOmfXyFPTwOR+Gz1dwwbHCJ4= X-MC-Unique: rgZjUUthOei7N9FZm9bKGA-1 X-Mimecast-MFC-AGG-ID: rgZjUUthOei7N9FZm9bKGA_1773962012 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1773962011; x=1774566811; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6RAHkTnj5upfaZ8SooBURZ2Qif/9bxeVdrP7OGRyeXk=; b=bqR1eNad5Fj9d26JyUbmBETAo/HJ31O3wHPCrDlQWKUeKkIVDR1tYgJiS5NqlqaF9F BGMtgzvvLUqPYvWV2DNbeUocKFJeEF8RyvPU4wt3gZW2S9lF/1wtbFExhgsxRmFNjIzX MhQChcPhgPewv+eZWkPllt2dAXq6Vee4JUMrVdXlOx8ORSgHc9z8hWipCR6vrg1GM/b5 xAOlPxNE4euSMoWMd97adNaZ8DlN01KT4xd9s/ezZkqpE1enWEAmp0YRkonP6N8FVim5 rd7bQEBPvPNdgJbb04eExyEqtvjrKazbj6CS6xN38bL++OXFLc2sUElG4Z9AZJmQl41n 5reA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962011; x=1774566811; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=6RAHkTnj5upfaZ8SooBURZ2Qif/9bxeVdrP7OGRyeXk=; b=Ad75l0AxiZIykufu7FE2K8r4z1C0BstmoNcBjHmgEscy992chu5XRXOfsB0Gvqdbwu YMi9Q0McMmyBkGXeonDwhfKPAYCpeInd/4Tz1RCio8hCnnkwzpvyJ3GzLuhI+Y3myHyY f7YHB5PqmMDSnj1P1u2oHG1jCy+IbvBDRcyHFez3Vl8iReicWTfnvcoadPaeDm+MyGR4 bh+BZyXqCC46RC1qKIwRd18yL/1qE07Yss47oVJygow3+u/GsV+8SG/KuHNXIRwQfqOc VtJUbQfOavDkRWU8ASn3EkMD45e8ldTIZE6EaH60c9yn/D3qnil0Ml44JUuHfrQNTfc+ rZ9A== X-Gm-Message-State: AOJu0YxB1QTxyoadwUj3ANsTBKcbEfLlDznmnO2oLKyf4g15advvMZgN zMDxFQWpAbx8Jws+TLxwY2hMwLBfmPcZy9l131TBk3GW5qKv+ZXtESSpi7zUavfD1f0VIrWBFwT Ir0gYeg8vwN4/yIbx2NcdaEqIZ6L8+Wwi5jSK19/lnVvZUvt6tHqtS3pY5W454TkDaq9JQGzSNo O70AyqjcTSUbEJNs6Fb/kUfn4yp+CygLFQNjNVCQ== X-Gm-Gg: ATEYQzw0Quu6Lmi5g5Pf8ZQcROyttBwGJ4wEbyboXmsOWF8wD+ox0gk03/nfuPThBy0 1P1KAupZCAPbskyQ8H8c5f7Xcsx4+K/BgGi/YuRvRHne6A6BjnfNLVoywnvnUUAeas/nyf6ayQh QK/Vb9ecG5AaSewO9HrK2GYrtAzWX3daVQYs687ZxQgdZohfTDqm0m9c1s3CgUbZ1QAf/KalsOp pzVoMIAUmbi8iK3Z9WU+EcJMWMH2nbo8W3lKE+7yXBza1+jT9nk27HxOPM0iI4c9hpOS+ktYWwM CNnsKlmXlOvW9HWRVijSoSoNIfzYcFR4Wq7FEIO4vorWrJSMy3ncRpIWFhBifDx5rh1c7G304ct AekYY1yo0Sg0GRQ== X-Received: by 2002:a05:622a:1823:b0:501:5152:f49f with SMTP id d75a77b69052e-50b374e59aamr17037791cf.46.1773962011334; Thu, 19 Mar 2026 16:13:31 -0700 (PDT) X-Received: by 2002:a05:622a:1823:b0:501:5152:f49f with SMTP id d75a77b69052e-50b374e59aamr17037201cf.46.1773962010754; Thu, 19 Mar 2026 16:13:30 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , Kirti Wankhede , "Maciej S . Szmigiero" , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Joao Martins , Alex Williamson , Yishai Hadas , Fabiano Rosas , Pranav Tyagi , peterx@redhat.com, Zhiyi Guo , Markus Armbruster , Avihai Horon , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH RFC 11/12] migration: Calculate expected downtime on demand Date: Thu, 19 Mar 2026 19:13:01 -0400 Message-ID: <20260319231302.123135-12-peterx@redhat.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260319231302.123135-1-peterx@redhat.com> References: <20260319231302.123135-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: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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: 1773962103609154100 Content-Type: text/plain; charset="utf-8" This value does not need to be calculated as frequent. Only calculate it on demand when query-migrate happened. With that we can remove the variable in MigrationState. This paves way for fixing this value to include all modules (not only RAM but others too). Signed-off-by: Peter Xu --- migration/migration.h | 1 - migration/migration.c | 26 ++++++++++++-------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index bf3ee6cc07..ba0f9e0f9c 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -359,7 +359,6 @@ struct MigrationState { /* Timestamp when VM is down (ms) to migrate the last stuff */ int64_t downtime_start; int64_t downtime; - int64_t expected_downtime; bool capabilities[MIGRATION_CAPABILITY__MAX]; int64_t setup_time; =20 diff --git a/migration/migration.c b/migration/migration.c index 56d605ede9..23c78b3a2c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1041,6 +1041,17 @@ static bool migrate_show_downtime(MigrationState *s) return (s->state =3D=3D MIGRATION_STATUS_COMPLETED) || migration_in_po= stcopy(); } =20 +/* Return expected downtime (unit: milliseconds) */ +int64_t migration_downtime_calc_expected(MigrationState *s) +{ + if (mig_stats.dirty_sync_count <=3D 1) { + return migrate_downtime_limit(); + } + + return 1.0 * mig_stats.dirty_bytes_last_sync / + migration_get_switchover_bw(s) * 1000; +} + static void populate_time_info(MigrationInfo *info, MigrationState *s) { info->has_status =3D true; @@ -1061,7 +1072,7 @@ static void populate_time_info(MigrationInfo *info, M= igrationState *s) info->downtime =3D s->downtime; } else { info->has_expected_downtime =3D true; - info->expected_downtime =3D s->expected_downtime; + info->expected_downtime =3D migration_downtime_calc_expected(s); } } =20 @@ -1649,7 +1660,6 @@ int migrate_init(MigrationState *s, Error **errp) s->mbps =3D 0.0; s->pages_per_second =3D 0.0; s->downtime =3D 0; - s->expected_downtime =3D 0; s->setup_time =3D 0; s->start_postcopy =3D false; s->migration_thread_running =3D false; @@ -3162,16 +3172,6 @@ static void migration_update_counters(MigrationState= *s, s->pages_per_second =3D (double) transferred_pages / (((double) time_spent / 1000.0)); =20 - /* - * if we haven't sent anything, we don't want to - * recalculate. 10000 is a small enough number for our purposes - */ - if (qatomic_read(&mig_stats.dirty_pages_rate) && - transferred > 10000) { - s->expected_downtime =3D - qatomic_read(&mig_stats.dirty_bytes_last_sync) / expected_bw_p= er_ms; - } - migration_rate_reset(); =20 update_iteration_initial_status(s); @@ -3817,8 +3817,6 @@ void migration_start_outgoing(MigrationState *s) bool resume =3D (s->state =3D=3D MIGRATION_STATUS_POSTCOPY_RECOVER_SET= UP); int ret; =20 - s->expected_downtime =3D migrate_downtime_limit(); - if (resume) { /* This is a resumed migration */ rate_limit =3D migrate_max_postcopy_bandwidth(); --=20 2.50.1