{"id":2233216,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2233216/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260505202640.1011006-15-peterx@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.1/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260505202640.1011006-15-peterx@redhat.com>","date":"2026-05-05T20:26:31","name":"[PULL,14/23] migration: Fix calculation of expected_downtime to take VFIO info","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"0b1e30004bf9d3299c4156bde0526847417d2a94","submitter":{"id":67717,"url":"http://patchwork.ozlabs.org/api/1.1/people/67717/?format=json","name":"Peter Xu","email":"peterx@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260505202640.1011006-15-peterx@redhat.com/mbox/","series":[{"id":502897,"url":"http://patchwork.ozlabs.org/api/1.1/series/502897/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=502897","date":"2026-05-05T20:26:17","name":"[PULL,01/23] migration: Fix blocking in POSTCOPY_DEVICE during package load","version":1,"mbox":"http://patchwork.ozlabs.org/series/502897/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2233216/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2233216/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=MdKK8UXL;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=google header.b=DWusmMnT;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g998t06Qsz1yJV\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 06 May 2026 06:29:18 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wKMMN-0004b7-14; Tue, 05 May 2026 16:27:15 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <peterx@redhat.com>) id 1wKMME-0004Tl-Ct\n for qemu-devel@nongnu.org; Tue, 05 May 2026 16:27:07 -0400","from us-smtp-delivery-124.mimecast.com ([170.10.133.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <peterx@redhat.com>) id 1wKMMC-0002db-PU\n for qemu-devel@nongnu.org; Tue, 05 May 2026 16:27:06 -0400","from mail-qv1-f69.google.com (mail-qv1-f69.google.com\n [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-20-2be3P9BEP_CRO5WP5KF-LA-1; Tue, 05 May 2026 16:27:02 -0400","by mail-qv1-f69.google.com with SMTP id\n 6a1803df08f44-8b597b14a22so10669136d6.0\n for <qemu-devel@nongnu.org>; Tue, 05 May 2026 13:27:02 -0700 (PDT)","from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id\n 6a1803df08f44-8b53c6b8123sm155283806d6.35.2026.05.05.13.26.59\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 05 May 2026 13:27:00 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1778012823;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=9WmFUP5dqUbxMM1tZndsShjc1KEJom3N3hcsbb3ZxQQ=;\n b=MdKK8UXL+/PA/opfipKtkhXQQPQ8Hr4VNcySliNxnIwheDeglvwC7cFsCPgtGTFX4iB5zX\n amoeMm1cFR8GoyiMdy5iio2bjmpjljqYjN5/wxKt08dMbRHOlrGBo6876y8LefPw1xKixq\n BxZHuntCSe+f9/9cGYX1GRslSNGBhUY=","v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1778012821; x=1778617621; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=9WmFUP5dqUbxMM1tZndsShjc1KEJom3N3hcsbb3ZxQQ=;\n b=DWusmMnTi8JNwRLJ/fzDG33CS+LnDFDdAzMcwPEyhTA8Xy9/77f1J+g5iNbnL5HMvK\n DHR9Jk08LDUl1snuxMnjN8SguPKWGP4WbQcXCeZSdM7FyPQeF1C089ZcKBtRFfLRm/dl\n kLzpnGNEuPAkKP4RWC7UZOgK+ruJ7ck9Qigi0F/kGCGvBIvbALdsQVgojz5rOPiv4Bji\n +ltbdinRtngxPLAFm35LtcE4sSk5qLbpD9qzjKuOKq2NPgOH4k5QdWPKLbn5JjfMg2HD\n pWdUPTwppqpBGVGiVPur3oBay0XvmLJmCOPGbHLgyTrpywECeIbo9cv2Rg4K6eYGaAoC\n yEMw=="],"X-MC-Unique":"2be3P9BEP_CRO5WP5KF-LA-1","X-Mimecast-MFC-AGG-ID":"2be3P9BEP_CRO5WP5KF-LA_1778012822","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1778012821; x=1778617621;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=9WmFUP5dqUbxMM1tZndsShjc1KEJom3N3hcsbb3ZxQQ=;\n b=lnR5SZl4TUiBY96bDSGGJPwoWHCwRwiWlrUDTdZPwIsdeYHI7rj9tXDpNlr1w9L4NU\n OczOYTzw3kYTlU2BBuogYDUfpfPhqv+mOlLTxhkl2o83VxhqNKpalZyyM6MrjWWFNrct\n Z3eYoLqKQxEafm9O0Sj1RyWjZaMWYnniQZptGMmUjD49iCJ2TKbZoPMitAfgPMPD/8QM\n SQab1342GXJDa9gIWyskBh8CsMkYHznkvB4+Y9ZabQ54cY+/pVObu2MC8aeTLnr1qJ9F\n iA167JGSWJ7YSF61IRSUzWoG9t7cOI2Lr3fRx8FaE0mV0PxEpGWYMCeXYDdfkbmqHJf6\n QD1g==","X-Gm-Message-State":"AOJu0YyZdRy3B62QkCL684f5tszc3JZkjL1X0S7nhY99Bk9duN9Ut3G4\n H1xRgTh2znari4EaXRFmo28QA4Y6kWkcOhTgA4DCamqshUxKmTMp4w5blEoRbC7T+A6r+bLekRu\n qwmSPOeCmxqvE4FWKORfXmgD9T8OXyavuHsJghZkt9V9iSRurEfFEBCnXHl0Vc1WMzImIUO24wQ\n iewFdghFNsoqZV55bnGGiBoJdhsWJh5IzQwxqT7Q==","X-Gm-Gg":"AeBDiesKtcf01AHrXdxzYwp8zXKZICS8S2NnndSvdEr4Bumr1x0Hx3/MAvpWWYMcZsK\n 0BATt7gHRFt5eT2XNyMBtful8EIoIOkC6fXPLi/mcgNW6ygraENypTF+vpP5mlhoW1LKu33IiXp\n qNdTVW46SnyKNn2tM+0i2j8Py68nvXS1KQs/6sZeGfAiQF+5W+X5pRUVD1cxfASJ4rEX0/PtyrR\n rVh3ADwC1lGdZeCDzAyONC/gPi8iM8czEFiqZPJy0cspuPK1qNrJ9A/UmFggNtCZZLpJgFoBzqu\n xJXSp0hZ0sezjj6eIv5os8VevqV92SBr7ZLz4xGFjnfxVtioOXTcthBcuQzLFi017Q2wmii8IZg\n kIs/bkkBfmQH8s3L38QpiLxY0iEnTKy+wjBr+aJ3qE4QfBdo9zklJfl0=","X-Received":["by 2002:a05:6214:5503:b0:896:fb99:f692 with SMTP id\n 6a1803df08f44-8bc2a3b6da3mr9953536d6.0.1778012821247;\n Tue, 05 May 2026 13:27:01 -0700 (PDT)","by 2002:a05:6214:5503:b0:896:fb99:f692 with SMTP id\n 6a1803df08f44-8bc2a3b6da3mr9952896d6.0.1778012820570;\n Tue, 05 May 2026 13:27:00 -0700 (PDT)"],"From":"Peter Xu <peterx@redhat.com>","To":"qemu-devel@nongnu.org","Cc":"Fabiano Rosas <farosas@suse.de>, Paolo Bonzini <pbonzini@redhat.com>,\n Peter Xu <peterx@redhat.com>,\n =?utf-8?q?C=C3=A9dric_Le_Goater?= <clg@redhat.com>,\n Juraj Marcin <jmarcin@redhat.com>","Subject":"[PULL 14/23] migration: Fix calculation of expected_downtime to take\n VFIO info","Date":"Tue,  5 May 2026 16:26:31 -0400","Message-ID":"<20260505202640.1011006-15-peterx@redhat.com>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260505202640.1011006-1-peterx@redhat.com>","References":"<20260505202640.1011006-1-peterx@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com","X-Spam_score_int":"-24","X-Spam_score":"-2.5","X-Spam_bar":"--","X-Spam_report":"(-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.443,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001,\n SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"QEMU will provide an expected downtime for the whole system during\nmigration, by remembering the total dirty RAM that we synced the last time,\ndivides the estimated switchover bandwidth.\n\nThat was flawed when VFIO is taking into account: consider there is a VFIO\nGPU device that contains GBs of data to migrate during stop phase.  Those\nwill not be accounted in this math.\n\nFix it by updating dirty_bytes_last_sync properly only when we go to the\nnext iteration, rather than hide this update in the RAM code.  Meanwhile,\nfetch the total (rather than RAM-only) portion of dirty bytes, so as to\ninclude GPU device states too.\n\nUpdate the comment of the field to reflect its new meaning.\n\nNow after this change, the expected-downtime to be read from query-migrate\nshould be very accurate even with VFIO devices involved.\n\nTested-by: Cédric Le Goater <clg@redhat.com>\nReviewed-by: Juraj Marcin <jmarcin@redhat.com>\nLink: https://lore.kernel.org/r/20260421202110.306051-13-peterx@redhat.com\nSigned-off-by: Peter Xu <peterx@redhat.com>\n---\n migration/migration-stats.h |  8 +++-----\n migration/migration.c       | 11 ++++++++---\n migration/ram.c             |  1 -\n 3 files changed, 11 insertions(+), 9 deletions(-)","diff":"diff --git a/migration/migration-stats.h b/migration/migration-stats.h\nindex 326ddb0088..1775b916df 100644\n--- a/migration/migration-stats.h\n+++ b/migration/migration-stats.h\n@@ -31,11 +31,9 @@\n  */\n typedef struct {\n     /*\n-     * Number of bytes that were dirty last time that we synced with\n-     * the guest memory.  We use that to calculate the downtime.  As\n-     * the remaining dirty amounts to what we know that is still dirty\n-     * since last iteration, not counting what the guest has dirtied\n-     * since we synchronized bitmaps.\n+     * Number of bytes that were reported dirty after the latest\n+     * system-wise synchronization of dirty information.  It is used to do\n+     * best-effort estimation on expected downtime.\n      */\n     uint64_t dirty_bytes_last_sync;\n     /*\ndiff --git a/migration/migration.c b/migration/migration.c\nindex d740d9df85..ab09dcbcf4 100644\n--- a/migration/migration.c\n+++ b/migration/migration.c\n@@ -3244,18 +3244,23 @@ static void migration_iteration_go_next(MigPendingData *pending)\n      */\n     qemu_savevm_query_pending(pending, true);\n \n+    /*\n+     * Update the dirty information for the whole system for this\n+     * iteration.  This value is used to calculate expected downtime.\n+     */\n+    qatomic_set(&mig_stats.dirty_bytes_last_sync, pending->total_bytes);\n+\n     /*\n      * Boost dirty sync count to reflect we finished one iteration.\n      *\n      * NOTE: we need to make sure when this happens (together with the\n      * event sent below) all modules have slow-synced the pending data\n-     * above.  That means a write mem barrier, but qatomic_add() should be\n-     * enough.\n+     * above and updated corresponding fields (e.g. dirty_bytes_last_sync).\n      *\n      * It's because a mgmt could wait on the iteration event to query again\n      * on pending data for policy changes (e.g. downtime adjustments).  The\n      * ordering will make sure the query will fetch the latest results from\n-     * all the modules.\n+     * all the modules on everything.\n      */\n     qatomic_add(&mig_stats.dirty_sync_count, 1);\n \ndiff --git a/migration/ram.c b/migration/ram.c\nindex ecd4b6165c..fc38ffbf8a 100644\n--- a/migration/ram.c\n+++ b/migration/ram.c\n@@ -1148,7 +1148,6 @@ static void migration_bitmap_sync(RAMState *rs, bool last_stage)\n             RAMBLOCK_FOREACH_NOT_IGNORED(block) {\n                 ramblock_sync_dirty_bitmap(rs, block);\n             }\n-            qatomic_set(&mig_stats.dirty_bytes_last_sync, ram_bytes_remaining());\n         }\n     }\n \n","prefixes":["PULL","14/23"]}