get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/1.0/patches/2221182/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2221182,
    "url": "http://patchwork.ozlabs.org/api/1.0/patches/2221182/?format=api",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/1.0/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": ""
    },
    "msgid": "<20260408165559.157108-10-peterx@redhat.com>",
    "date": "2026-04-08T16:55:53",
    "name": "[09/14] migration: Move iteration counter out of RAM",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "0cab4d58668c187508ec922e49742d08f3f923ae",
    "submitter": {
        "id": 67717,
        "url": "http://patchwork.ozlabs.org/api/1.0/people/67717/?format=api",
        "name": "Peter Xu",
        "email": "peterx@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260408165559.157108-10-peterx@redhat.com/mbox/",
    "series": [
        {
            "id": 499176,
            "url": "http://patchwork.ozlabs.org/api/1.0/series/499176/?format=api",
            "date": "2026-04-08T16:55:55",
            "name": "migration/vfio: Fix a few issues on API misuse or statistic reports",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/499176/mbox/"
        }
    ],
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2221182/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=RZh6bLeV;\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=MxCI426j;\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=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"
        ],
        "Received": [
            "from lists.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 4frYJG6rJ4z1yD3\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 09 Apr 2026 05:38:06 +1000 (AEST)",
            "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wAYSq-0004bx-FM; Wed, 08 Apr 2026 15:21:24 -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 1wAY3l-00063V-60\n for qemu-devel@nongnu.org; Wed, 08 Apr 2026 14:55:29 -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 1wAWCQ-000292-NX\n for qemu-devel@nongnu.org; Wed, 08 Apr 2026 12:56:20 -0400",
            "from mail-qt1-f199.google.com (mail-qt1-f199.google.com\n [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-18-4x2l-3FPNV-p47qJrOZcDA-1; Wed, 08 Apr 2026 12:56:17 -0400",
            "by mail-qt1-f199.google.com with SMTP id\n d75a77b69052e-50b4987c698so2805501cf.0\n for <qemu-devel@nongnu.org>; Wed, 08 Apr 2026 09:56:16 -0700 (PDT)",
            "from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id\n d75a77b69052e-50d712c2617sm130491901cf.31.2026.04.08.09.56.13\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 08 Apr 2026 09:56:14 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1775667378;\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=5hD/iKEkJCQLVYmt/ko9Id263R4U72ejWLOEm2tj8VI=;\n b=RZh6bLeVQXv3MOxziswUAT/s968LXLq+5h9U0XkYL+TfM1F/L79vv157LTKSVD6/1FU8ED\n hz8MiNLapkq5Dtzwc3qb2nRo/mGAXY+PG31alFF81GxG7oor8e+/pWRUZlaoPkPmW1O4xH\n Ag24i2FXwbtOC7r3dfsHnozUMX7lNO4=",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1775667376; x=1776272176; 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=5hD/iKEkJCQLVYmt/ko9Id263R4U72ejWLOEm2tj8VI=;\n b=MxCI426jDoyLbdOQKgMuAG/PP9y/DgZORY5K/ukK6F/08c2R/xLDcVjPDqQTLrdfik\n MFMPr7V4RSjNk7OZx18V4HI1B9cl7WLixToHp/3D7/UCxFNhGoMSR4E/jQi3x9KVRsCO\n DNtZsufLCO/nGxa3Gx3SU3CQg4mZS+R7PLsB9h2L/p+TysDCEEI3j5JMFwabP08NLPEM\n 9P6Up2wdJSA0ULn6btyqoKiM1foidKQihpqQ4LHbHO2zLaebKYQkImXoxCajsCo2X/+9\n cY4IJvxFuNpmQ3pmnAZYzUWxars4OhCoMDEiu9Oaz9m2gkPJNqawfKo/kjvQj1ncpy66\n 885w=="
        ],
        "X-MC-Unique": "4x2l-3FPNV-p47qJrOZcDA-1",
        "X-Mimecast-MFC-AGG-ID": "4x2l-3FPNV-p47qJrOZcDA_1775667376",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775667376; x=1776272176;\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=5hD/iKEkJCQLVYmt/ko9Id263R4U72ejWLOEm2tj8VI=;\n b=WnLuTE+oTRduMtJXoNkRGLgf95lvmBxdW74DCYgBzAKGxQBA9GdN+FLwqA/osxHe7W\n 5l0msz5Oz32eqHbZM5ndhb1QXW2zTIgMiHVWQAnQ3mYs0MpNPfi4SNQ5VhHtQq9kS8Lm\n hUINoB0QLnkG7Ean9/3Gj6FF6O3zJudW0IuBN/atPAaEIMgFCdthH4nUcbANBPmIkhMl\n gEdo5CH9cQpuFezcdbaYrzQmCcOl1NSBCFSi3cOTv2zAejvm1KNqDMRf2e1dIp0Fzltm\n KPR/El5HLK1atUPUGDc/DEhwKiiz462CNoHOhv/0WiH8nmNqz2Hbq/ek/munyyAylzHC\n QMrg==",
        "X-Gm-Message-State": "AOJu0YzD9oXLQbMMp80j5AMJ6j5jaTqRKRxUFLgqwuZdh3xgB0LxO538\n ocMPwlJcRF+262C4wLjgKA7ULgucCJkrqZJZDv11XqO7Bdow7iCzwA+arPDjVfxUyLK49tJVI4D\n YYBLlLnXPEGMhX4oBgSDc0SZRIyhCcxPOYq7GAgzElcGtl2xpXnVpLkgf6jBgieSuTRiSsMVolU\n swG6huKqa9elpvoAksmgh97qjh/GAuyMxZXj8vIQ==",
        "X-Gm-Gg": "AeBDieuh+8oiRFi1KS45S0v4GiXb0nkEWwg4U6BYhJGt/bno/ff0+uFEWwPfktEhNMH\n JfvtYHvPsmedDBeOFU8xV5erMwx/Qqujp6Hx0RUcXikoentq8bBe3Lv/Hv76A6gnHtGwsVQah0M\n 9gX/kPzFVL5BUmD9lNS4J02c+v6PNh7RFwb2MzfS/NyMF36xsfuN32R06F1zKoDnU8XfWuWEmKN\n RUC9pF09KnZJC6y77ATFC4RMPJIOGpzINzkttbSX2ehxb/oBvKMVS88OBK/9G5jltnOsazjrCTE\n W0pLInSqAgdfzsXo3BOl/oViDPahyUmUDBSnRA8GRvzL556OKj9EC6YYsKlryuOYB2EIzFtqExS\n 0ei3NCSnf7sDNx46jYgXLrxwAMQQGTCR4DB6viyXoY80q",
        "X-Received": [
            "by 2002:a05:622a:1207:b0:4ff:b32b:cdf9 with SMTP id\n d75a77b69052e-50dc1a1b80bmr3300321cf.14.1775667375838;\n Wed, 08 Apr 2026 09:56:15 -0700 (PDT)",
            "by 2002:a05:622a:1207:b0:4ff:b32b:cdf9 with SMTP id\n d75a77b69052e-50dc1a1b80bmr3299731cf.14.1775667375169;\n Wed, 08 Apr 2026 09:56:15 -0700 (PDT)"
        ],
        "From": "Peter Xu <peterx@redhat.com>",
        "To": "qemu-devel@nongnu.org",
        "Cc": "\"Maciej S . Szmigiero\" <mail@maciej.szmigiero.name>, =?utf-8?q?Daniel_P_?=\n\t=?utf-8?q?=2E_Berrang=C3=A9?= <berrange@redhat.com>,\n Zhiyi Guo <zhguo@redhat.com>, Juraj Marcin <jmarcin@redhat.com>,\n Peter Xu <peterx@redhat.com>, Prasad Pandit <ppandit@redhat.com>,\n Avihai Horon <avihaih@nvidia.com>, Kirti Wankhede <kwankhede@nvidia.com>,\n\t=?utf-8?q?C=C3=A9dric_Le_Goater?= <clg@redhat.com>,\n Fabiano Rosas <farosas@suse.de>, Joao Martins <joao.m.martins@oracle.com>,\n Markus Armbruster <armbru@redhat.com>, Alex Williamson <alex@shazbot.org>,\n Hyman Huang <yong.huang@smartx.com>, Prasad Pandit <pjp@fedoraproject.org>",
        "Subject": "[PATCH 09/14] migration: Move iteration counter out of RAM",
        "Date": "Wed,  8 Apr 2026 12:55:53 -0400",
        "Message-ID": "<20260408165559.157108-10-peterx@redhat.com>",
        "X-Mailer": "git-send-email 2.53.0",
        "In-Reply-To": "<20260408165559.157108-1-peterx@redhat.com>",
        "References": "<20260408165559.157108-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": "-25",
        "X-Spam_score": "-2.6",
        "X-Spam_bar": "--",
        "X-Spam_report": "(-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54,\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_H2=0.001,\n RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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": "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 a9ee3360e1..57d91ad9e3 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 /*\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": [
        "09/14"
    ]
}