From nobody Sat Sep 26 20:51:55 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=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1789280758; cv=none; d=zohomail.com; s=zohoarc; b=BaqfJCI9fTJ7/WZ+etc6bZZ/JPWWxX5Zs75T5jcw7X7csEVOwwo0bbJO9tpt71PhkB9ib85TVEOW96HWRVrmxKNo1DJ5z0NOPlFCVRFbXj9WEADkbVjUrPT4k5lhm6Lart8wdXBtbMdzJYpGmVt5YJMTHZBVBIaPhAswRjel+Ik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789280758; h=Content-Type: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=MwbegZEI14F01jCXZp5cYkEbYaeq2J4T7CeUkrDUIh0=; b=YNU/PGaYW+2yh3Fk0IHdypvp/giBuTGRQxIQy9EHJffV2apf20GWabGr9aA98LqvZyVY73lLq6HkhfHlywI8yFgLFvFFngfJ8UAWNbj7Sv4KbLK/ds2sj2QWFyVHMIf3xkb5IBDiRTvF/59oHK9ai4qSAB+GwQF9K0cqoSxyckg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789280758815748.8618168820105; Sat, 12 Sep 2026 23:25:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x5deg-0000Mr-RF; Sun, 13 Sep 2026 02:25:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x5def-0000Mb-Qh for qemu-devel@nongnu.org; Sun, 13 Sep 2026 02:25:33 -0400 Received: from va-1-111.ptr.blmpb.com ([209.127.230.111]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x5dec-0002mk-DN for qemu-devel@nongnu.org; Sun, 13 Sep 2026 02:25:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1789280721; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=MwbegZEI14F01jCXZp5cYkEbYaeq2J4T7CeUkrDUIh0=; b=LGf7K/6zX+gvZ+Vo5yULoKIcGmbCC6KqFSObQClNv1oapDIYrSr65ol4E4jPRtaTb6JrEu yo2xqRaFaxRH99JgA5AZnNbmKJD8tzKaxS4fqv4pV6a8jHHCMbUR9xdvXXemn5hMNh5doR 59rDVzwNbm8JDv/o33Mi+kvnKfs/6hdEWdd087iGo6Rb6YdkYqmjtgjxnBInTv/8hJaHCY SdkuOVH0dbG+sAiCpohsAD8A0wmktkJGD14PixVbkukqvpUSjdFDgabuk/Rrjd4feD/ByK +J3yExYy9G9CQPnb+/N62D8PEMuEhRzHZxsDzXcLo2mXjOny6s0h66eb+oB9vA== To: , From: "Yanfei Xu" Date: Sun, 13 Sep 2026 14:24:52 +0800 X-Mailer: git-send-email 2.20.1 Content-Transfer-Encoding: quoted-printable X-Lms-Return-Path: Subject: [PATCH v3 1/4] migration/ram: Add RAM round synchronization notifiers Mime-Version: 1.0 In-Reply-To: <20260913062455.940447-1-yanfei.xu@bytedance.com> References: <20260913062455.940447-1-yanfei.xu@bytedance.com> Cc: , , , , "Yanfei Xu" Message-Id: <20260913062455.940447-2-yanfei.xu@bytedance.com> X-Original-From: Yanfei Xu 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.127.230.111; envelope-from=yanfei.xu@bytedance.com; helo=va-1-111.ptr.blmpb.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 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 @bytedance.com) X-ZM-MESSAGEID: 1789280762240158500 Content-Type: text/plain; charset="utf-8" find_dirty_block() directly invokes multifd's per-round synchronization when the RAM scan wraps. Other transports need the same boundary to order page versions. Add a return-valued notifier for RAM round completion and register multifd's existing synchronization through it. This keeps the current behavior while allowing other transports to synchronize at the same boundary. Signed-off-by: Yanfei Xu Reviewed-by: Peter Xu Tested-by: Jack Wang --- migration/multifd-nocomp.c | 24 ++++++++++++++++++++ migration/ram.c | 45 +++++++++++++++++++++++++++++++++----- migration/ram.h | 12 ++++++++++ 3 files changed, 75 insertions(+), 6 deletions(-) diff --git a/migration/multifd-nocomp.c b/migration/multifd-nocomp.c index 9f7a792fa7..3067c19cc6 100644 --- a/migration/multifd-nocomp.c +++ b/migration/multifd-nocomp.c @@ -19,6 +19,7 @@ #include "multifd-colo.h" #include "options.h" #include "migration.h" +#include "ram.h" #include "qapi/error.h" #include "qemu/cutils.h" #include "qemu/error-report.h" @@ -27,6 +28,28 @@ =20 static MultiFDSendData *multifd_ram_send; =20 +static int multifd_ram_round_notify(NotifierWithReturn *n G_GNUC_UNUSED, + void *data, Error **errp) +{ + RAMRoundNotifyData *round_data =3D data; + QEMUFile *f =3D round_data->file; + int ret; + + if (!multifd_ram_sync_per_round()) { + return 0; + } + + ret =3D multifd_ram_flush_and_sync(f); + if (ret < 0) { + error_setg(errp, "multifd RAM round synchronization failed"); + } + return ret; +} + +static NotifierWithReturn multifd_ram_round_notifier =3D { + .notify =3D multifd_ram_round_notify, +}; + void multifd_ram_payload_alloc(MultiFDPages_t *pages) { pages->offset =3D g_new0(ram_addr_t, multifd_ram_page_count()); @@ -471,6 +494,7 @@ static const MultiFDMethods multifd_nocomp_ops =3D { static void multifd_nocomp_register(void) { multifd_register_ops(MULTIFD_COMPRESSION_NONE, &multifd_nocomp_ops); + ram_round_add_notifier(&multifd_ram_round_notifier); } =20 migration_init(multifd_nocomp_register); diff --git a/migration/ram.c b/migration/ram.c index 8918b2f03b..2dd898b305 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -440,6 +440,8 @@ typedef struct RAMState RAMState; static RAMState *ram_state; =20 static NotifierWithReturnList precopy_notifier_list; +static NotifierWithReturnList ram_round_notifier_list =3D + NOTIFIER_WITH_RETURN_LIST_INITIALIZER(ram_round_notifier_list); =20 /* Whether postcopy has queued requests? */ static bool postcopy_has_request(RAMState *rs) @@ -470,6 +472,38 @@ int precopy_notify(PrecopyNotifyReason reason, Error *= *errp) return notifier_with_return_list_notify(&precopy_notifier_list, &pnd, = errp); } =20 +void ram_round_add_notifier(NotifierWithReturn *n) +{ + notifier_with_return_list_add(&ram_round_notifier_list, n); +} + +void ram_round_remove_notifier(NotifierWithReturn *n) +{ + notifier_with_return_remove(n); +} + +static int ram_round_notify(QEMUFile *f) +{ + RAMRoundNotifyData data =3D { + .file =3D f, + }; + Error *local_err =3D NULL; + int ret; + + ret =3D notifier_with_return_list_notify(&ram_round_notifier_list, &da= ta, + &local_err); + if (ret) { + if (local_err) { + error_report_err(local_err); + } else { + error_report("RAM round notifier failed: %d", ret); + } + return -1; + } + + return 0; +} + uint64_t ram_bytes_remaining(void) { return ram_state ? (ram_state->migration_dirty_pages * TARGET_PAGE_SIZ= E) : @@ -1380,12 +1414,11 @@ static int find_dirty_block(RAMState *rs, PageSearc= hStatus *pss) pss->page =3D 0; pss->block =3D QLIST_NEXT_RCU(pss->block, next); if (!pss->block) { - if (multifd_ram_sync_per_round()) { - QEMUFile *f =3D rs->pss[RAM_CHANNEL_PRECOPY].pss_channel; - int ret =3D multifd_ram_flush_and_sync(f); - if (ret < 0) { - return ret; - } + QEMUFile *f =3D rs->pss[RAM_CHANNEL_PRECOPY].pss_channel; + int ret =3D ram_round_notify(f); + + if (ret < 0) { + return ret; } =20 /* Hit the end of the list */ diff --git a/migration/ram.h b/migration/ram.h index 41697a7599..84f10087e8 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -31,6 +31,7 @@ =20 #include "qapi/qapi-types-migration.h" #include "exec/cpu-common.h" +#include "qemu/notify.h" #include "system/ram_addr.h" #include "io/channel.h" =20 @@ -95,6 +96,17 @@ void ram_handle_zero(void *host, uint64_t size); void ram_transferred_add(uint64_t bytes); void ram_release_page(const char *rbname, uint64_t offset); =20 +/* + * The RAM round notifier is invoked whenever the migration RAM core + * completes one full scan of guest memory. + */ +typedef struct RAMRoundNotifyData { + QEMUFile *file; +} RAMRoundNotifyData; + +void ram_round_add_notifier(NotifierWithReturn *n); +void ram_round_remove_notifier(NotifierWithReturn *n); + int ramblock_recv_bitmap_test(RAMBlock *rb, void *host_addr); bool ramblock_recv_bitmap_test_byte_offset(RAMBlock *rb, uint64_t byte_off= set); void ramblock_recv_bitmap_set(RAMBlock *rb, void *host_addr); --=20 2.20.1 From nobody Sat Sep 26 20:51:55 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=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1789280759; cv=none; d=zohomail.com; s=zohoarc; b=JQ0Oa9D4KHZe/ZBTzhDtVEpVwqIxhUW8dRnUc+xtnuuX6ez8KDuFfJ+tWO82Pl85hg6rgg1T69Rlq+Jn3cCimHL6L79n9qEalKulU6c8+4UR1Dv7vPljKtVv4Qv7wB2Y6Dw3lhKq9uL/Rjd3Pl9M6zzeaDkLnErWg+laCz+6BIc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789280759; h=Content-Type: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=rgSYZtlmiY5NJdMpd9oRG7QhQ62tMG20JkaP9+NpoEU=; b=GEna4IZoScscflXMVR4aThuGe9pi7KOzFC4n+A4Y07UOOIs7bwkZen+lIHDyNr6PDMtdo7S5vnTpiExZ1v9jVu1pG5H5vrnKQxL592zQDeVfVs9IhNM0qdvIkZOVyvpF7mEkvPMkKBfeHYDWujWTiW9rRg24Pl70aJ8Mr/948vw= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789280759048750.5898498893997; Sat, 12 Sep 2026 23:25:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x5dek-0000Nd-9e; Sun, 13 Sep 2026 02:25:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x5dei-0000NT-Uu for qemu-devel@nongnu.org; Sun, 13 Sep 2026 02:25:37 -0400 Received: from va-1-113.ptr.blmpb.com ([209.127.230.113]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x5deh-0002nT-9l for qemu-devel@nongnu.org; Sun, 13 Sep 2026 02:25:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1789280730; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=rgSYZtlmiY5NJdMpd9oRG7QhQ62tMG20JkaP9+NpoEU=; b=qFl2d6S//0guplYAqE496+pUIJ89e5oWddSCnCy21RskfPaNUEVtZM8+DptQfF7/XqBlsW XV6iIu68SY/vnIvlCZJB9O93tK/sOLQuWc0Oh7NBhbB7UOV3G6bh2Z8wzz2pT7Y1wxHdDo iS/lgsU+tVJMxGwNn05WipmkRA4hoViwTtdNF+qzvNRh5jlZOuEsyDtu78yFZyMmOoap8L FwY0Tc6o+PzKPQvXcQZpswdNk2++MS28yQgAQo8O4b24DFIQ+QH/6w1sEvnEjegkKfMeF8 f94uNzCuq96NW+wZaLDGZibupqx73mSalcac9SIhg1WGNoCSM/+UUpOLi6BZHw== Message-Id: <20260913062455.940447-3-yanfei.xu@bytedance.com> X-Mailer: git-send-email 2.20.1 X-Lms-Return-Path: References: <20260913062455.940447-1-yanfei.xu@bytedance.com> Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 In-Reply-To: <20260913062455.940447-1-yanfei.xu@bytedance.com> X-Original-From: Yanfei Xu To: , Cc: , , , , "Yanfei Xu" Subject: [PATCH v3 2/4] migration/rdma: Drain writes at RAM round boundaries From: "Yanfei Xu" Date: Sun, 13 Sep 2026 14:24:53 +0800 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.127.230.113; envelope-from=yanfei.xu@bytedance.com; helo=va-1-113.ptr.blmpb.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 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 @bytedance.com) X-ZM-MESSAGEID: 1789280762666158500 Content-Type: text/plain; charset="utf-8" rdma_registration_stop() runs after every ram_save_iterate() call, which can stop before a complete RAM scan because of rate limiting. Draining there ties the completion barrier to a SaveVM section rather than the point where the scan wraps and a newer page version can be sent. Register an RDMA RAM round notifier that drains all outstanding writes. Keep posting the buffered tail in rdma_registration_stop() so it remains ordered before REGISTER_FINISHED. Signed-off-by: Yanfei Xu Reviewed-by: Peter Xu Tested-by: Jack Wang --- migration/rdma.c | 58 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index b8a0e39d2a..16e9c6c30e 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2627,21 +2627,16 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *i= oc, return done; } =20 -/* - * Block until all the outstanding chunks have been delivered by the hardw= are. - */ -static int qemu_rdma_drain_cq(RDMAContext *rdma) +/* Block until all outstanding writes have been delivered by the hardware.= */ +static int qemu_rdma_drain_cq(RDMAContext *rdma, Error **errp) { - Error *err =3D NULL; - - if (qemu_rdma_write_flush(rdma, &err) < 0) { - error_report_err(err); + if (qemu_rdma_write_flush(rdma, errp) < 0) { return -1; } =20 while (rdma->nb_sent) { if (qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL) < 0= ) { - error_report("rdma migration: complete polling error!"); + error_setg(errp, "rdma migration: completion polling error"); return -1; } } @@ -2649,6 +2644,38 @@ static int qemu_rdma_drain_cq(RDMAContext *rdma) return 0; } =20 +static int rdma_ram_round_notify(NotifierWithReturn *n G_GNUC_UNUSED, + void *data, Error **errp) +{ + RAMRoundNotifyData *round_data =3D data; + QEMUFile *f; + QIOChannelRDMA *rioc; + RDMAContext *rdma; + + if (!migrate_rdma()) { + return 0; + } + + f =3D round_data->file; + RCU_READ_LOCK_GUARD(); + rioc =3D QIO_CHANNEL_RDMA(qemu_file_get_ioc(f)); + rdma =3D qatomic_rcu_read(&rioc->rdmaout); + if (!rdma) { + error_setg(errp, "RDMA output context is not set"); + return -1; + } + + if (rdma_errored(rdma)) { + error_setg(errp, "RDMA is in an error state"); + return -1; + } + + return qemu_rdma_drain_cq(rdma, errp); +} + +static NotifierWithReturn rdma_ram_round_notifier =3D { + .notify =3D rdma_ram_round_notify, +}; =20 static int qio_channel_rdma_set_blocking(QIOChannel *ioc, bool blocking, @@ -3549,7 +3576,8 @@ int rdma_registration_start(QEMUFile *f, uint64_t fla= gs) =20 /* * Inform dest that dynamic registrations are done for now. - * First, flush writes, if any. + * Post any buffered write before sending the control marker. Outstanding + * writes are drained at the RAM scan round boundary. */ int rdma_registration_stop(QEMUFile *f, uint64_t flags) { @@ -3575,9 +3603,10 @@ int rdma_registration_stop(QEMUFile *f, uint64_t fla= gs) } =20 qemu_fflush(f); - ret =3D qemu_rdma_drain_cq(rdma); + ret =3D qemu_rdma_write_flush(rdma, &err); =20 if (ret < 0) { + error_report_err(err); goto err; } =20 @@ -3711,6 +3740,13 @@ static void qio_channel_rdma_register_types(void) =20 type_init(qio_channel_rdma_register_types); =20 +static void rdma_register_migration_notifiers(void) +{ + ram_round_add_notifier(&rdma_ram_round_notifier); +} + +migration_init(rdma_register_migration_notifiers); + static QIOChannel *rdma_new_input(RDMAContext *rdma) { QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(object_new(TYPE_QIO_CHANNEL_= RDMA)); --=20 2.20.1 From nobody Sat Sep 26 20:51:55 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=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1789280784; cv=none; d=zohomail.com; s=zohoarc; b=ilXudprrPh7rQQD7XreCKyTtv8HtS8BZ16yKg+Lhl2GalAxsEajpV9wiwuNAqkcsFzQZAQfUZGrlnAy1lGUqEZUNTi7VcDrymESs/UjVCTfFy/GTovx3iDm+YTudnrDeGnnQzVSBGy96AtD2GlCasNOFjsEwdEwKkpD5fR3thV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789280784; h=Content-Type: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=hjUCxRH7owdhiSIR0fePXWNWgjxCC/rztZABGwgn0Wo=; b=DNAI0ruXQPKH9olnZ5GMX/Uaq0dbrlPSMfXTVF6Af7rf/LZX6LCe39oB/z1tVSCexD5kNK1hVynGgnGJHWc6kFU+2864Zl5RcfsptZnYw4MNMRnFsrD5jEW8C9DO9EFnaDiHwWCtIZfZwfoHrzS4An2wLflpD5RdmpZFTofonSY= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789280784558713.0243967848146; Sat, 12 Sep 2026 23:26:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x5dev-0000Oq-9V; Sun, 13 Sep 2026 02:25:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x5det-0000OT-Em for qemu-devel@nongnu.org; Sun, 13 Sep 2026 02:25:47 -0400 Received: from va-1-112.ptr.blmpb.com ([209.127.230.112]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x5deq-0002o3-TU for qemu-devel@nongnu.org; Sun, 13 Sep 2026 02:25:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1789280740; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=hjUCxRH7owdhiSIR0fePXWNWgjxCC/rztZABGwgn0Wo=; b=pvNJWbWDLFmKw7RjMiNrHP4bdoBRDnW2XUVCyW+MR+V54GlXnSvU8DGVs4KxlxXNAsrnZY rHYZKqj65ZJOFcxBCZIzYtyZeEu12iomBPFNdiu5tGTMUtTU6zUN4FdGosOLOx/4FNltpd 2u2gSMqtV+Ir609RdJsBpeY77khfUloaTWXa3Q5nREp8MmajDxCT5T55ZLIJhDI/TeaNxD Y0vN5zRRDcvuCtqCRzuuyyYIlqPL1VOZ+PGBIz+w2Ih7ayr5J0ikyksSTLSeaAJEBtthYx xkul5bxq7Pt4p5iqifgR+8rz/A/hOk4Oh1tr2eBtsRJp0bdUZF9KxugAn9+fhw== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Lms-Return-Path: X-Mailer: git-send-email 2.20.1 X-Original-From: Yanfei Xu References: <20260913062455.940447-1-yanfei.xu@bytedance.com> From: "Yanfei Xu" Subject: [PATCH v3 3/4] migration/rdma: Allow multiple in-flight writes per chunk Date: Sun, 13 Sep 2026 14:24:54 +0800 To: , Cc: , , , , "Yanfei Xu" Message-Id: <20260913062455.940447-4-yanfei.xu@bytedance.com> In-Reply-To: <20260913062455.940447-1-yanfei.xu@bytedance.com> 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.127.230.112; envelope-from=yanfei.xu@bytedance.com; helo=va-1-112.ptr.blmpb.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 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 @bytedance.com) X-ZM-MESSAGEID: 1789280787137158500 Content-Type: text/plain; charset="utf-8" qemu_rdma_write_one() waits for an earlier write that shares the same registration chunk, even when the dirty ranges do not overlap. This serializes sparse writes and leaves send queue capacity unused. RAM round notifiers now provide the completion barrier before a newer page version can be sent, and the obsolete unregister path no longer requires per-chunk serialization. Remove the wait. The global nb_sent count continues to manage CQ and send queue resources. Signed-off-by: Yanfei Xu Reviewed-by: Peter Xu Tested-by: Jack Wang --- migration/rdma.c | 19 +------------------ migration/trace-events | 1 - 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 16e9c6c30e..6f9b474e29 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1740,7 +1740,7 @@ static int qemu_rdma_write_one(RDMAContext *rdma, struct ibv_sge sge; struct ibv_send_wr send_wr =3D { 0 }; struct ibv_send_wr *bad_wr; - int reg_result_idx, ret, count =3D 0; + int reg_result_idx, ret; uint64_t chunk, chunks; uint64_t chunk_size =3D migrate_rdma_chunk_size(); uint8_t *chunk_start, *chunk_end; @@ -1772,23 +1772,6 @@ retry: =20 chunk_end =3D ram_chunk_end(block, chunk + chunks); =20 - - while (test_bit(chunk, block->transit_bitmap)) { - (void)count; - trace_rdma_write_one_block(count++, current_index, chunk, - sge.addr, length, rdma->nb_sent, block->nb_chunks); - - ret =3D qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL); - - if (ret < 0) { - error_setg(errp, "Failed to Wait for previous write to complet= e " - "block %d chunk %" PRIu64 - " current %" PRIu64 " len %" PRIu64 " %d", - current_index, chunk, sge.addr, length, rdma->nb_sent); - return -1; - } - } - if (!rdma->pin_all) { if (!block->remote_keys[chunk]) { /* diff --git a/migration/trace-events b/migration/trace-events index a9b02b3113..70d083f3fe 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -243,7 +243,6 @@ rdma_register_odp_mr(const char *name) "Try to register= On-Demand Paging memory rdma_advise_mr(const char *name, uint32_t len, uint64_t addr, const char *= res) "Try to advise block %s prefetch at %" PRIu32 "@0x%" PRIx64 ": %s" rdma_resolve_host_trying(const char *host, const char *ip) "Trying %s =3D>= %s" rdma_write_flush(int sent) "sent total: %d" -rdma_write_one_block(int count, int block, uint64_t chunk, uint64_t curren= t, uint64_t len, int nb_sent, int nb_chunks) "(%d) Not clobbering: block: %= d chunk %" PRIu64 " current %" PRIu64 " len %" PRIu64 " %d %d" rdma_write_one_post(uint64_t chunk, long addr, long remote, uint32_t len) = "Posting chunk: %" PRIu64 ", addr: 0x%lx remote: 0x%lx, bytes %" PRIu32 rdma_write_one_queue_full(void) "" rdma_write_one_recvregres(int mykey, int theirkey, uint64_t chunk) "Receiv= ed registration result: my key: 0x%x their key 0x%x, chunk %" PRIu64 --=20 2.20.1 From nobody Sat Sep 26 20:51:55 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=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1789280794; cv=none; d=zohomail.com; s=zohoarc; b=T6RNm3YTWhYzaBA7lpjw+8UasVyrhgjyLN1A6ynvLGlx5+fTE7InRGe2rMpQ1KUlDeBPTL+o9Gb0dy/lvFMk4WzB4H7HSoCpc0jR+RBYolwBn3fHPCHHGwb1KVh+t5375APopct4RgQdXRbBI1z5u1NxnQ0bcxxj1vSpTAHd8Gg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789280794; h=Content-Type: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=papa7K0qt3qBqtxuBR0A7TO9lTB6ZZXXJ86FLrBGYyo=; b=NphYNAcsc3WxCDZVphgff7Llq0/hS7Y3iuZYRXOGnae8fH3ZoDyXDi51MQ+p4KCfMUlif5p0ae7+HHwt3l5lZOssnjVMG56q/DD+WJa8YRNyRLcbaASe/W8CooIjynaFCwxm+s0n/tZj9Z+dWK8o5lCH+xgYQTzHp+ULOsfbnJk= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789280794060508.9007690863241; Sat, 12 Sep 2026 23:26:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x5df7-0000YO-6R; Sun, 13 Sep 2026 02:26:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x5df4-0000Ut-5w for qemu-devel@nongnu.org; Sun, 13 Sep 2026 02:25:58 -0400 Received: from va-1-114.ptr.blmpb.com ([209.127.230.114]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x5df0-0002oe-1T for qemu-devel@nongnu.org; Sun, 13 Sep 2026 02:25:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1789280749; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=papa7K0qt3qBqtxuBR0A7TO9lTB6ZZXXJ86FLrBGYyo=; b=fTQGlDDPbhC5DZaBBUAFaBBU+/0ahVv6tQcXOj1HVRrZ7M1FTKQOxXL8CebRivvIGwqc7Q PrDnGBiRuWZwUEwwnuUeBTQsfOafq4a9DnhzvbU448gEXBDgQPSWUV4y9I9TsyAQIPe8K7 owtfqha1awAvESSOnEf0vCbR4ddJOaB0Jx0sfnD2crmMa/ODvQBh8jgpfM8UxaFRyox8Hl X9l6/KtqSocA4yiJkisKvmseXUMO4jOl5iAaG6+x03yXrC9f2Bhw9nvvP88E5m7GPlaBYc W6cOZfcOKvlj5k1CqGXt+o68L0tf4y35oUsxdiZKBychCxOq3XAdgmNncpgmUw== Subject: [PATCH v3 4/4] migration/rdma: Remove unused transit bitmap Date: Sun, 13 Sep 2026 14:24:55 +0800 Mime-Version: 1.0 X-Original-From: Yanfei Xu X-Mailer: git-send-email 2.20.1 From: "Yanfei Xu" Content-Transfer-Encoding: quoted-printable To: , Cc: , , , , "Yanfei Xu" Message-Id: <20260913062455.940447-5-yanfei.xu@bytedance.com> References: <20260913062455.940447-1-yanfei.xu@bytedance.com> In-Reply-To: <20260913062455.940447-1-yanfei.xu@bytedance.com> X-Lms-Return-Path: 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=lists1p.gnu.org; Received-SPF: pass client-ip=209.127.230.114; envelope-from=yanfei.xu@bytedance.com; helo=va-1-114.ptr.blmpb.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 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 @bytedance.com) X-ZM-MESSAGEID: 1789280795204158500 Content-Type: text/plain; charset="utf-8" After the per-chunk write wait is removed, transit_bitmap is no longer read. The remaining set and clear operations only maintain unused state. Remove the bitmap and simplify the block lifecycle tracepoints. Signed-off-by: Yanfei Xu Reviewed-by: Peter Xu Tested-by: Jack Wang --- migration/rdma.c | 20 +++----------------- migration/trace-events | 4 ++-- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 6f9b474e29..7a884ecb6e 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -30,7 +30,6 @@ #include "qemu/module.h" #include "qemu/rcu.h" #include "qemu/sockets.h" -#include "qemu/bitmap.h" #include "qemu/coroutine.h" #include "system/memory.h" #include @@ -197,7 +196,6 @@ typedef struct RDMALocalBlock { int index; /* which block are we */ unsigned int src_index; /* (Only used on dest) */ int nb_chunks; - unsigned long *transit_bitmap; } RDMALocalBlock; =20 /* @@ -571,8 +569,6 @@ static void rdma_add_block(RDMAContext *rdma, const cha= r *block_name, block->index =3D local->nb_blocks; block->src_index =3D ~0U; /* Filled in by the receipt of the block lis= t */ block->nb_chunks =3D ram_chunk_index(host_addr, host_addr + length) + = 1UL; - block->transit_bitmap =3D bitmap_new(block->nb_chunks); - bitmap_clear(block->transit_bitmap, 0, block->nb_chunks); block->remote_keys =3D g_new0(uint32_t, block->nb_chunks); =20 if (rdma->blockmap) { @@ -583,8 +579,6 @@ static void rdma_add_block(RDMAContext *rdma, const cha= r *block_name, (uintptr_t) block->local_host_addr, block->offset, block->length, (uintptr_t) (block->local_host_addr + block->leng= th), - BITS_TO_LONGS(block->nb_chunks) * - sizeof(unsigned long) * 8, block->nb_chunks); =20 local->nb_blocks++; @@ -654,9 +648,6 @@ static void rdma_delete_block(RDMAContext *rdma, RDMALo= calBlock *block) block->mr =3D NULL; } =20 - g_free(block->transit_bitmap); - block->transit_bitmap =3D NULL; - g_free(block->remote_keys); block->remote_keys =3D NULL; =20 @@ -693,9 +684,8 @@ static void rdma_delete_block(RDMAContext *rdma, RDMALo= calBlock *block) =20 trace_rdma_delete_block(block, (uintptr_t)block->local_host_addr, block->offset, block->length, - (uintptr_t)(block->local_host_addr + block->le= ngth), - BITS_TO_LONGS(block->nb_chunks) * - sizeof(unsigned long) * 8, block->nb_chunks= ); + (uintptr_t)(block->local_host_addr + block->len= gth), + block->nb_chunks); =20 g_free(old); =20 @@ -1221,8 +1211,6 @@ static int qemu_rdma_poll(RDMAContext *rdma, struct i= bv_cq *cq, index, chunk, block->local_host_addr, (void *)(uintptr_t)block->remote_host_a= ddr); =20 - clear_bit(chunk, block->transit_bitmap); - if (rdma->nb_sent > 0) { rdma->nb_sent--; } @@ -1877,8 +1865,7 @@ retry: /* * Encode the ram block index and chunk within this wrid. * We will use this information at the time of completion - * to figure out which bitmap to check against and then which - * chunk in the bitmap to look for. + * to identify the completed write in trace output. */ send_wr.wr_id =3D qemu_rdma_make_wrid(RDMA_WRID_RDMA_WRITE, current_index, chunk); @@ -1916,7 +1903,6 @@ retry: return -1; } =20 - set_bit(chunk, block->transit_bitmap); qatomic_add(&mig_stats.normal_pages, sge.length / qemu_target_page_siz= e()); /* * We are adding to transferred the amount of data written, but no diff --git a/migration/trace-events b/migration/trace-events index 70d083f3fe..4b3239636c 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -249,9 +249,9 @@ rdma_write_one_recvregres(int mykey, int theirkey, uint= 64_t chunk) "Received reg rdma_write_one_sendreg(uint64_t chunk, int len, int index, int64_t offset)= "Sending registration request chunk %" PRIu64 " for %d bytes, index: %d, o= ffset: %" PRId64 rdma_write_one_top(uint64_t chunks, uint64_t size) "Writing %" PRIu64 " ch= unks, (%" PRIu64 " MB)" rdma_write_one_zero(uint64_t chunk, int len, int index, int64_t offset) "E= ntire chunk is zero, sending compress: %" PRIu64 " for %d bytes, index: %d,= offset: %" PRId64 -rdma_add_block(const char *block_name, int block, uint64_t addr, uint64_t = offset, uint64_t len, uint64_t end, uint64_t bits, int chunks) "Added Block= : '%s':%d, addr: %" PRIu64 ", offset: %" PRIu64 " length: %" PRIu64 " end: = %" PRIu64 " bits %" PRIu64 " chunks %d" +rdma_add_block(const char *block_name, int block, uint64_t addr, uint64_t = offset, uint64_t len, uint64_t end, int chunks) "Added Block: '%s':%d, addr= : %" PRIu64 ", offset: %" PRIu64 " length: %" PRIu64 " end: %" PRIu64 " chu= nks %d" rdma_block_notification_handle(const char *name, int index) "%s at %d" -rdma_delete_block(void *block, uint64_t addr, uint64_t offset, uint64_t le= n, uint64_t end, uint64_t bits, int chunks) "Deleted Block: %p, addr: %" PR= Iu64 ", offset: %" PRIu64 " length: %" PRIu64 " end: %" PRIu64 " bits %" PR= Iu64 " chunks %d" +rdma_delete_block(void *block, uint64_t addr, uint64_t offset, uint64_t le= n, uint64_t end, int chunks) "Deleted Block: %p, addr: %" PRIu64 ", offset:= %" PRIu64 " length: %" PRIu64 " end: %" PRIu64 " chunks %d" rdma_registration_handle_compress(int64_t length, int index, int64_t offse= t) "Zapping zero chunk: %" PRId64 " bytes, index %d, offset %" PRId64 rdma_registration_handle_finished(void) "" rdma_registration_handle_ram_blocks(void) "" --=20 2.20.1