From nobody Sat May 30 17:43:37 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=none dis=none) header.from=linux.alibaba.com ARC-Seal: i=1; a=rsa-sha256; t=1780038328; cv=none; d=zohomail.com; s=zohoarc; b=aqNvgPi0aGgRkEF41074CXN4KiFPsa0saOw6BetNrpUvK8banlP3/uaYyEDK8M/g+f9FqbnaDVGGDVfC0J/J/vkVqnICDTN6/TYwgJRQOjYkna+oZ+L/qMW7+ajTbnq9cG9l6oqjPzvWTY1/wBQ/Xj3AVR9KshFpdk+Q21gqwc4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780038328; 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=7+C14dR0GlrhuSHKR315K7FEJDVBDQmOfdM8LokophA=; b=ZWANe1aEfoMZvwSD6/N6Kw51oW3+pTCFCqWGDN5jKeSOtylfFMw5DX/azSxD9NiZDpXUTs6fnaBRTSAUntRnCYTdlX+rt8WJzx61EelFJmt+lRa2RQNgI0jdJhTLV+PcP54crutfYTi8AqLD3dpv35x7EYpHQ7gXYW3tWyFiT+c= 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=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780038328478819.0518758782754; Fri, 29 May 2026 00:05:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wSrGx-0000WC-54; Fri, 29 May 2026 03:04:47 -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 1wSrGm-0000VY-4D for qemu-devel@nongnu.org; Fri, 29 May 2026 03:04:37 -0400 Received: from [115.124.30.101] (helo=out30-101.freemail.mail.aliyun.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSrGj-0008BE-Ks for qemu-devel@nongnu.org; Fri, 29 May 2026 03:04:35 -0400 Received: from localhost(mailfrom:guobin@linux.alibaba.com fp:SMTPD_---0X3ofNIT_1780038250 cluster:ay36) by smtp.aliyun-inc.com; Fri, 29 May 2026 15:04:10 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1780038251; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=7+C14dR0GlrhuSHKR315K7FEJDVBDQmOfdM8LokophA=; b=sTPFqc5/FuqCA8Zvi1LlnGf9MIkfZytsOLxbU8T1IbOCP/bM5QeeXSTnyeKaVhJux6Ns5f4/allQ6NXo7kX1bILYrppbx0TsNBOY4RcaoIWhXRjOR9muYf2qE3offQeWWxl3pwFd7JWrWRqE0yVRaB5oh1jQWY/VNgi6ixzE2uA= X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R171e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=maildocker-contentspam033037033178; MF=guobin@linux.alibaba.com; NM=1; PH=DS; RN=4; SR=0; TI=SMTPD_---0X3ofNIT_1780038250; From: Bin Guo To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , Li Zhijian Subject: [PATCH 1/2] migration/rdma: honor blocking mode in QIOChannelRDMA readv Date: Fri, 29 May 2026 15:04:07 +0800 Message-ID: <20260529070408.92651-2-guobin@linux.alibaba.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260529070408.92651-1-guobin@linux.alibaba.com> References: <20260529070408.92651-1-guobin@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 115.124.30.101 (deferred) 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=115.124.30.101; envelope-from=guobin@linux.alibaba.com; helo=out30-101.freemail.mail.aliyun.com X-Spam_score_int: -166 X-Spam_score: -16.7 X-Spam_bar: ---------------- X-Spam_report: (-16.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5 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 @linux.alibaba.com) X-ZM-MESSAGEID: 1780038330259158500 Content-Type: text/plain; charset="utf-8" QIOChannelRDMA's readv ignored the blocking flag set via io_set_blocking. In blocking mode it returned immediately instead of waiting for data, unlike other QIOChannel implementations. Loop on qemu_rdma_exchange_recv() when the channel is blocking and the receive buffer cannot satisfy the request. Also remove the stale XXX comments about unimplemented blocking support. Signed-off-by: Bin Guo --- migration/rdma.c | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 3e37a1d440..201cb9eb12 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -388,7 +388,7 @@ struct QIOChannelRDMA { QIOChannel parent; RDMAContext *rdmain; RDMAContext *rdmaout; - bool blocking; /* XXX we don't actually honour this yet */ + bool blocking; }; =20 /* @@ -2710,32 +2710,29 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *i= oc, break; } =20 - - /* We've got nothing at all, so lets wait for - * more to arrive - */ - ret =3D qemu_rdma_exchange_recv(rdma, &head, RDMA_CONTROL_QEMU_FIL= E, - errp); - - if (ret < 0) { - rdma->errored =3D true; - return -1; - } - /* - * SEND was received with new bytes, now try again. + * We've got nothing at all, so lets wait for + * more to arrive. */ - len =3D qemu_rdma_fill(rdma, data, want, 0); - done +=3D len; - want -=3D len; - - /* Still didn't get enough, so lets just return */ - if (want) { - if (done =3D=3D 0) { - return QIO_CHANNEL_ERR_BLOCK; - } else { - break; + do { + ret =3D qemu_rdma_exchange_recv(rdma, &head, + RDMA_CONTROL_QEMU_FILE, errp); + if (ret < 0) { + rdma->errored =3D true; + return -1; } + + /* + * SEND was received with new bytes, now try again. + */ + len =3D qemu_rdma_fill(rdma, data, want, 0); + done +=3D len; + want -=3D len; + data +=3D len; + } while (want && rioc->blocking); + + if (want && done =3D=3D 0) { + return QIO_CHANNEL_ERR_BLOCK; } } return done; @@ -2771,7 +2768,6 @@ static int qio_channel_rdma_set_blocking(QIOChannel *= ioc, Error **errp) { QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(ioc); - /* XXX we should make readv/writev actually honour this :-) */ rioc->blocking =3D blocking; return 0; } --=20 2.50.1 (Apple Git-155) From nobody Sat May 30 17:43:37 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=none dis=none) header.from=linux.alibaba.com ARC-Seal: i=1; a=rsa-sha256; t=1780038328; cv=none; d=zohomail.com; s=zohoarc; b=LPEMskyQaL0QOGSPZnuwntCW1bXdeg2aavNslrKv6TWdf7DzNmPsofPJ1nSyPs8UmRMfSd61wsQ/5NVBih+nDFnF/HBIp9pnvW3Dz9ngINQgC26AdQIgNXgMKHziXuFkJtIOXfsVoVlK5f82FlQK00gooF9+BHUcndUKY+C7qNY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780038328; 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=y+7IVOun7XJaruVrw/QTeMg6P/KxPIealuUnPh9JiTM=; b=QXq4+lcsk4YbeTETHEszSN2zrGWt8AtD93sqNWoqonOwB1ifTOAgpA42ZIG/xAZfrcf4shxPWeN+gPAGBWGU5/D2RYuYLNum5uYeCyad2a5pNzgkXatW+3zsbXEM2ggVBNE59OWbqZ19Qj2nWgVUrwCVEo84OgpVndcqjm78gno= 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=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780038328888320.86056979889327; Fri, 29 May 2026 00:05:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wSrGv-0000WB-Ay; Fri, 29 May 2026 03:04:45 -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 1wSrGn-0000Vl-Pw for qemu-devel@nongnu.org; Fri, 29 May 2026 03:04:39 -0400 Received: from [115.124.30.98] (helo=out30-98.freemail.mail.aliyun.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSrGj-0008BI-2n for qemu-devel@nongnu.org; Fri, 29 May 2026 03:04:37 -0400 Received: from localhost(mailfrom:guobin@linux.alibaba.com fp:SMTPD_---0X3ofNIx_1780038251 cluster:ay36) by smtp.aliyun-inc.com; Fri, 29 May 2026 15:04:11 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1780038252; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=y+7IVOun7XJaruVrw/QTeMg6P/KxPIealuUnPh9JiTM=; b=v65JRLpboX7PF1ryuuEPtQgnHewl9DYnBToQIzvZick17Yy1FC+Jc+aNUZnjsnQ/tJHMuhHM3Hng/HN+wmXde4AqrE0qTV9X+AkGgXLrlKhno/DbAsKIPXTPfG+GPeEstBnluHw2/k5uSTMCpMwfAK9MhRPM9nclbCfe2H5+5bo= X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R141e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=maildocker-contentspam033037026112; MF=guobin@linux.alibaba.com; NM=1; PH=DS; RN=4; SR=0; TI=SMTPD_---0X3ofNIx_1780038251; From: Bin Guo To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , Li Zhijian Subject: [PATCH 2/2] migration/rdma: account transferred bytes for zero page compression Date: Fri, 29 May 2026 15:04:08 +0800 Message-ID: <20260529070408.92651-3-guobin@linux.alibaba.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260529070408.92651-1-guobin@linux.alibaba.com> References: <20260529070408.92651-1-guobin@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 115.124.30.98 (deferred) 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=115.124.30.98; envelope-from=guobin@linux.alibaba.com; helo=out30-98.freemail.mail.aliyun.com X-Spam_score_int: -166 X-Spam_score: -16.7 X-Spam_bar: ---------------- X-Spam_report: (-16.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5 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 @linux.alibaba.com) X-ZM-MESSAGEID: 1780038330251158500 Content-Type: text/plain; charset="utf-8" RDMA zero page compression sends an RDMA_CONTROL_COMPRESS message instead of an RDMA Write, but the transfer accounting (mig_stats.rdma_bytes and ram_transferred_add) was not updated. This caused migration progress and bandwidth to be undercounted. Account the wire cost (RDMAControlHeader + RDMACompress payload), matching how the non-RDMA path accounts for zero page markers. Signed-off-by: Bin Guo --- migration/rdma.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 201cb9eb12..f08468881f 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1930,15 +1930,15 @@ retry: } =20 /* - * TODO: Here we are sending something, but we are not - * accounting for anything transferred. The following is = wrong: - * - * stat64_add(&mig_stats.rdma_bytes, sge.length); - * - * because we are using some kind of compression. I - * would think that head.len would be the more similar - * thing to a correct value. + * Account for the control message we just sent. + * The actual bytes on the wire are the control header + * plus the RDMACompress payload, not the original page + * size (which was never transferred). */ + qatomic_add(&mig_stats.rdma_bytes, + sizeof(RDMAControlHeader) + sizeof(RDMACompres= s)); + ram_transferred_add(sizeof(RDMAControlHeader) + + sizeof(RDMACompress)); qatomic_add(&mig_stats.zero_pages, sge.length / qemu_target_page_size()); return 1; --=20 2.50.1 (Apple Git-155)