Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2225935/?format=api
{ "id": 2225935, "url": "http://patchwork.ozlabs.org/api/patches/2225935/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260421202110.306051-10-peterx@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "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": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260421202110.306051-10-peterx@redhat.com>", "list_archive_url": null, "date": "2026-04-21T20:21:03", "name": "[v2,09/16] migration: Move iteration counter out of RAM", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "646333047d58b3edc74a56ff0985d9eb69f9be1b", "submitter": { "id": 67717, "url": "http://patchwork.ozlabs.org/api/people/67717/?format=api", "name": "Peter Xu", "email": "peterx@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260421202110.306051-10-peterx@redhat.com/mbox/", "series": [ { "id": 500889, "url": "http://patchwork.ozlabs.org/api/series/500889/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=500889", "date": "2026-04-21T20:20:55", "name": "migration/vfio: Fix a few issues on API misuse or statistic reports", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/500889/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2225935/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2225935/checks/", "tags": {}, "related": [], "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=KQ8DF3R/;\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=nYLQ90EB;\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 4g0Yh34sDQz1yGs\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 06:22:59 +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 1wFHbI-00010y-N4; Tue, 21 Apr 2026 16:21:40 -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 1wFHbB-0000xt-6h\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:33 -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 1wFHb9-0008Rb-DR\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:32 -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-544-jexQ8lLwPkuCz7eSybJSuA-1; Tue, 21 Apr 2026 16:21:29 -0400", "by mail-qv1-f69.google.com with SMTP id\n 6a1803df08f44-8aca6f796d5so78637766d6.0\n for <qemu-devel@nongnu.org>; Tue, 21 Apr 2026 13:21:29 -0700 (PDT)", "from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id\n 6a1803df08f44-8b02ae5c26csm114343556d6.31.2026.04.21.13.21.26\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 21 Apr 2026 13:21:27 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776802890;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=zyCQ0G6YIo2w22cNA+aGKrtBN8bxCdOvHJsgQDrXsUI=;\n b=KQ8DF3R/IEKf8XwXg+0n8Rm0QdN0nHfSb2VYnVOwBsn694pISZuSNYEcFeGd3N/rtZnRvB\n 9eL2FG29ZnHBlHU+onF1fzdTRDr2K+H8CfVje7PHnX+i7UmD0f0bn/TJ4m9mF5p0lBh1Sx\n aaRAPHkfFhURr5MaIQEj0BRstp2LVyk=", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1776802888; x=1777407688; 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=zyCQ0G6YIo2w22cNA+aGKrtBN8bxCdOvHJsgQDrXsUI=;\n b=nYLQ90EBhYSbSvUkcfq/KLtwRF8jBhalbwe8xgMXWPTIL66mwJ8HGehKIPWwJ8NkKE\n JxsvpSTOsp/b3esGCVDL60+gHOIJAnNytknNEaLREs0U7PeHxU3SVJb6CK3ur8Aovfp4\n eWDIQJ/PxoJ40HAoio9CgyzMIMhwuuSRX5mX/apIkUGlD+E4KIUQhX6pjfz+j/JEMdbm\n rJxATpKcqkTnUXbgQ0gXII3yqp/CJagLYTYHiSwkgCme0m3TXyHQlq7zztDOqG/C5ub1\n 1bSS/KjXrfUodIPSuXFytOHPpBPn9vbI1Je0EuD5kK1N6fvi8RvqGN3hskJmTA5j0nnD\n /UyA==" ], "X-MC-Unique": "jexQ8lLwPkuCz7eSybJSuA-1", "X-Mimecast-MFC-AGG-ID": "jexQ8lLwPkuCz7eSybJSuA_1776802889", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776802888; x=1777407688;\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=zyCQ0G6YIo2w22cNA+aGKrtBN8bxCdOvHJsgQDrXsUI=;\n b=MVN1wICCpsHlbaCEodk5B506m2DlZe4Yk23XXTGNtedIpl5dyKZxrZUdtzvNlCwi2f\n iSVh7cNvzveaB11zQbIbLSMcUfYbPFRwZao9Pe5LhbkSuDN2ncK2MKW3mm9H1w42XLFq\n KmakjSn9BjHJL4PNJ7bEX9pHqUbTPFGnyzQpWZW8c9u7eqnHpMAtOewHBSvdhPNUr3qX\n H0WaTRi0wHjo0xvW4f4SfNPD6w0moBo8w4VztE1p54PXmRhdhURV8xVAFypEJnhKUd0G\n RAqndTeQNZtd4slzOc40z5JztT4cSylI/t0cw+Go33/9KHFSfKOYuO/5bjfw3KOJHPBa\n EDUw==", "X-Gm-Message-State": "AOJu0YwY9liU+dA9wvtcIHPKLzaPdYsJ/+ZDjlxbcJN+eTDWGQr7C/JP\n LYcmEzgUOgTjbT0U1BAox3EYizHHkBAGFA3pnRBE6C0etPxTEbHDB9Ry3RU4dve0AdofmbJDqCA\n pBZ6Qc+2KhL1i7PK/ASZtXDeZq0m6Jlh+7tiJc5paVAStFoknNmtg51A06LAVVS6xA2H6q/QdFV\n yIatpFZH6biAlHFcfoY6eBvPRM9AmH4oR/X2gKQw==", "X-Gm-Gg": "AeBDiesksd/3oaoYPsHorLRU7SMcSdGPd6qjB12VPiLp8udBgoBw4iT+LK9WtjKAkpc\n MiwB2jmFOyFFU2pWo0ZPC4i2kvoyJU0qufhiqEn1SFs+m3sr1A9ScTMGWwfavfQUuAj7FJcbOvN\n B8uwo1nSwW9fHjbhDuBEzXQ6/EvxNZFNeqRijNhDxphXct9y7BAGoncDIR5n+62MbXZDszYKGgm\n W1Yc5J+GzyBBoauouHB4loaWfgnnODVCujc6FaQMDmWaef0a9cSvrZXa11Vz6r6WgAqv1e6zhNt\n YFFCV8bE/ZxhC+TxuUYxeQjvLiO5nYLbu8SH6bY7gNMwBESvCY+p585IrZgCHM/pGQKfC1dqycT\n quYosyFU/OXGxlRT9PVmO855ximiF84gBRECFg+e2rqR/vAr0DRS7/OkM3w==", "X-Received": [ "by 2002:a05:6214:d47:b0:89c:8a0f:55a0 with SMTP id\n 6a1803df08f44-8b0280923demr315154236d6.16.1776802888418;\n Tue, 21 Apr 2026 13:21:28 -0700 (PDT)", "by 2002:a05:6214:d47:b0:89c:8a0f:55a0 with SMTP id\n 6a1803df08f44-8b0280923demr315153596d6.16.1776802887829;\n Tue, 21 Apr 2026 13:21:27 -0700 (PDT)" ], "From": "Peter Xu <peterx@redhat.com>", "To": "qemu-devel@nongnu.org", "Cc": "Joao Martins <joao.m.martins@oracle.com>,\n Markus Armbruster <armbru@redhat.com>,\n =?utf-8?q?C=C3=A9dric_Le_Goater?= <clg@redhat.com>,\n Avihai Horon <avihaih@nvidia.com>,\n =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= <berrange@redhat.com>,\n Fabiano Rosas <farosas@suse.de>, Prasad Pandit <ppandit@redhat.com>,\n Alex Williamson <alex@shazbot.org>, Kirti Wankhede <kwankhede@nvidia.com>,\n Zhiyi Guo <zhguo@redhat.com>, Peter Xu <peterx@redhat.com>,\n \"Maciej S . Szmigiero\" <mail@maciej.szmigiero.name>,\n Juraj Marcin <jmarcin@redhat.com>, Hyman Huang <yong.huang@smartx.com>,\n Prasad Pandit <pjp@fedoraproject.org>", "Subject": "[PATCH v2 09/16] migration: Move iteration counter out of RAM", "Date": "Tue, 21 Apr 2026 16:21:03 -0400", "Message-ID": "<20260421202110.306051-10-peterx@redhat.com>", "X-Mailer": "git-send-email 2.53.0", "In-Reply-To": "<20260421202110.306051-1-peterx@redhat.com>", "References": "<20260421202110.306051-1-peterx@redhat.com>", "MIME-Version": "1.0", "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": "-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,\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, SPF_HELO_PASS=-0.001,\n 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": "It used to hide in RAM dirty sync path. Now with more modules being able\nto slow sync on dirty information, keeping it there may not be good anymore\nbecause it's not RAM's own concept for iterations: all modules should\nfollow.\n\nMore importantly, mgmt may try to query dirty info (to make policy\ndecisions like adjusting downtime) by listening to iteration count changes\nvia QMP events. So we must make sure the boost of iterations only happens\n_after_ the dirty sync operations with whatever form (RAM's dirty bitmap\nsync, or VFIO's different ioctls to fetch latest dirty info from kernel).\n\nMove this to core migration path to manage, together with the event\ngeneration, so that it can be well ordered with the sync operations for all\nmodules.\n\nThis brings a good side effect that we should have an old issue regarding\nto cpu_throttle_dirty_sync_timer_tick() which can randomly boost iteration\ncounts (because it invokes sync ops). Now it won't, which is actually the\nright behavior.\n\nSaid that, we have code (not only QEMU, but likely mgmt too) assuming the\n1st iteration will always shows dirty count to 1. Make it initialized with\n1 this time, because we'll miss the dirty sync for setup() on boosting this\ncounter now.\n\nReviewed-by: Hyman Huang <yong.huang@smartx.com>\nReviewed-by: Prasad Pandit <pjp@fedoraproject.org>\nReviewed-by: Juraj Marcin <jmarcin@redhat.com>\nSigned-off-by: Peter Xu <peterx@redhat.com>\n---\n migration/migration-stats.h | 3 ++-\n migration/migration.c | 29 ++++++++++++++++++++++++++---\n migration/ram.c | 6 ------\n 3 files changed, 28 insertions(+), 10 deletions(-)", "diff": "diff --git a/migration/migration-stats.h b/migration/migration-stats.h\nindex 1153520f7a..326ddb0088 100644\n--- a/migration/migration-stats.h\n+++ b/migration/migration-stats.h\n@@ -43,7 +43,8 @@ typedef struct {\n */\n uint64_t dirty_pages_rate;\n /*\n- * Number of times we have synchronized guest bitmaps.\n+ * Number of times we have synchronized guest bitmaps. This always\n+ * starts from 1 for the 1st iteration.\n */\n uint64_t dirty_sync_count;\n /*\ndiff --git a/migration/migration.c b/migration/migration.c\nindex 4b54fda4d7..e3f82baaac 100644\n--- a/migration/migration.c\n+++ b/migration/migration.c\n@@ -1654,10 +1654,15 @@ int migrate_init(MigrationState *s, Error **errp)\n s->threshold_size = 0;\n s->switchover_acked = false;\n s->rdma_migration = false;\n+\n /*\n- * set mig_stats memory to zero for a new migration\n+ * set mig_stats memory to zero for a new migration.. except the\n+ * iteration counter, which we want to make sure it returns 1 for the\n+ * first iteration.\n */\n memset(&mig_stats, 0, sizeof(mig_stats));\n+ mig_stats.dirty_sync_count = 1;\n+\n migration_reset_vfio_bytes_transferred();\n \n s->postcopy_package_loaded = false;\n@@ -3230,10 +3235,28 @@ static bool migration_iteration_next_ready(MigrationState *s,\n static void migration_iteration_go_next(MigPendingData *pending)\n {\n /*\n- * Do a slow sync will achieve this. TODO: move RAM iteration code\n- * into the core layer.\n+ * Do a slow sync first before boosting the iteration count.\n */\n qemu_savevm_query_pending(pending, true);\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+ *\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+ */\n+ qatomic_add(&mig_stats.dirty_sync_count, 1);\n+\n+ if (migrate_events()) {\n+ qapi_event_send_migration_pass(mig_stats.dirty_sync_count);\n+ }\n }\n \n static bool postcopy_should_start(MigrationState *s, MigPendingData *pending)\ndiff --git a/migration/ram.c b/migration/ram.c\nindex e5b7217bf5..686162643d 100644\n--- a/migration/ram.c\n+++ b/migration/ram.c\n@@ -1136,8 +1136,6 @@ static void migration_bitmap_sync(RAMState *rs, bool last_stage)\n RAMBlock *block;\n int64_t end_time;\n \n- qatomic_add(&mig_stats.dirty_sync_count, 1);\n-\n if (!rs->time_last_bitmap_sync) {\n rs->time_last_bitmap_sync = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);\n }\n@@ -1172,10 +1170,6 @@ static void migration_bitmap_sync(RAMState *rs, bool last_stage)\n rs->num_dirty_pages_period = 0;\n rs->bytes_xfer_prev = migration_transferred_bytes();\n }\n- if (migrate_events()) {\n- uint64_t generation = qatomic_read(&mig_stats.dirty_sync_count);\n- qapi_event_send_migration_pass(generation);\n- }\n }\n \n void migration_bitmap_sync_precopy(bool last_stage)\n", "prefixes": [ "v2", "09/16" ] }