From nobody Sat Sep 26 23:05:15 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=1787451529; cv=none; d=zohomail.com; s=zohoarc; b=NseuryDwX+S8DyjkpjEjpTSVdgjjn0yY2Vk94RFKn235CEntDti6xn6+ymwnvtWEaJsEGgno3AUCanMFNIVK7GtD/epkmtbdDCQQCQw5jROxSfwNb4zFneKGduPs6ImNHb9w97zyVhCLOag+/ebIcJ2GRCE92yNm5k3jAwOlhIU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787451529; 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=N5+2bqvMJBohMIJ/TaOyNOxxW36IgEtPtyFNbhZ6KFw=; b=SxUqTOUG1QV9JNy69VQy/ozC3YMknmmwYFGUo9XP8k5QBOtVZUzV6E5Gpb2CeVuJPmXNpoSt3hLVzzh/0shqDKOp1kP9/dz0LjBSPLdSAruKBJR0i8duoOwQ8nfv8bd+pKRKl5C5+Lx9xZtpH/+b9f5Wv0p+hDU97B5fI9T4Lko= 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 1787451529405885.011932353989; Sat, 22 Aug 2026 19:18:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxxmW-0004Un-F5; Sat, 22 Aug 2026 22:17:56 -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 1wxxmT-0004UH-4E for qemu-devel@nongnu.org; Sat, 22 Aug 2026 22:17:53 -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 1wxxmO-0005Is-VT for qemu-devel@nongnu.org; Sat, 22 Aug 2026 22:17:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1787451462; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=N5+2bqvMJBohMIJ/TaOyNOxxW36IgEtPtyFNbhZ6KFw=; b=EBcvnv93lYKbb/CRlxK2a0A6q7DbptpJQA8EAR0E3l/gw8FVpHIGjd7H03AjGmaXKpcCNS /98/ABHMZqBffMJnnK+5i6onlTz54OJ0uxLyLstOqGMuGgsLJ5EzMqICRoh3p+AWS4i6Ax IXuwZm13Gt/PWyEj8EWgvwwNHSOhBuwdFHYZFnRvJXVY0SjjirOInlSrAEMGgzSOzrqzpO iFFkjqOcY/TuSKSmDmtMtOm22+ps4N4iqS5J+TclKwztbAMx1+bSJnnTUKBIuZQk/w338F BAeHTYbMbwmpq8zMSIgEilutgOwny1629irz1MamDpIV7A5ZcMFGxq18wCuoQA== In-Reply-To: <20260823021657.2824542-1-yanfei.xu@bytedance.com> X-Original-From: Yanfei Xu Content-Transfer-Encoding: quoted-printable X-Lms-Return-Path: From: "Yanfei Xu" Mime-Version: 1.0 Message-Id: <20260823021657.2824542-2-yanfei.xu@bytedance.com> X-Mailer: git-send-email 2.20.1 To: Subject: [PATCH v3 1/3] migration/rdma: Fix write-side shutdown Date: Sun, 23 Aug 2026 10:16:55 +0800 References: <20260823021657.2824542-1-yanfei.xu@bytedance.com> Cc: , , , , , "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.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: 1787451531290158500 Content-Type: text/plain; charset="utf-8" qio_channel_rdma_shutdown() reads rdmain for both the input and output contexts. As a result, a write-side shutdown marks the input context as errored while leaving the output context active. A shutdown of both directions also fails to stop the output context. Read rdmaout from the output context so each shutdown direction marks the corresponding RDMA context as errored. Fixes: 54db882f073a ("migration: implement the shutdown for RDMA QIOChannel= ") Signed-off-by: Yanfei Xu Reviewed-by: Fabiano Rosas Reviewed-by: Peter Xu Reviewed-by: Jack Wang --- migration/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index c076dc04e8..fc6cb75167 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2993,7 +2993,7 @@ qio_channel_rdma_shutdown(QIOChannel *ioc, RCU_READ_LOCK_GUARD(); =20 rdmain =3D qatomic_rcu_read(&rioc->rdmain); - rdmaout =3D qatomic_rcu_read(&rioc->rdmain); + rdmaout =3D qatomic_rcu_read(&rioc->rdmaout); =20 switch (how) { case QIO_CHANNEL_SHUTDOWN_READ: --=20 2.20.1 From nobody Sat Sep 26 23:05:15 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=1787451508; cv=none; d=zohomail.com; s=zohoarc; b=fv9kYuYADHsN6lnbD/qwEI866lrHMiRZfYFNomr/ScNfonZV1TDgRloOeHex0x0NU5NXm2qiyEqNlivxfaYX5Z+i0T8BMhm9ywuuwbKz6ytK9kAOxR5i9WzOXLuc8fASZ55YIifkdf5ZpMbM7MQqKe8XW2WboEC9wytuvtzW5ms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787451508; 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=q2BARWfHcvKfbW6h1+IRJLV3nlhcCm+a4H9HWSWUOqA=; b=f7tmVbsDned923NqaNyfH7oUZTG2xT6694BqC2eKD0T1lAFH3iQWPZleX5txo8KAvf4SlLHFOTTo3m6LhUdUWNBhOimPse/trNOWnN7hYG8lDrlieG2qHjZw4nhKz5GeUOpa9lPd987pewIFyaIBp8JccXW2ubiQ0RhGSeojdlI= 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 178745150817453.92406759448602; Sat, 22 Aug 2026 19:18:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxxmd-0004Ve-SG; Sat, 22 Aug 2026 22:18:03 -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 1wxxmb-0004VO-NP for qemu-devel@nongnu.org; Sat, 22 Aug 2026 22:18:01 -0400 Received: from va-1-115.ptr.blmpb.com ([209.127.230.115]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wxxma-0005Kw-0o for qemu-devel@nongnu.org; Sat, 22 Aug 2026 22:18:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1787451474; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=q2BARWfHcvKfbW6h1+IRJLV3nlhcCm+a4H9HWSWUOqA=; b=JCt4zsnMnqPVQ1TN+Du6LtjrhT2FPuaY7M4fkyTLo62b4jQlXVc+Igjn019NI5Z7RWfESC v9rsfKWh0F+sf17/Dx6MvIyR4IsxsRNfIKBb2tkNr4v9ePocMieE9lwDWcFeeVzWnvovP3 2wJ5D8kjYSbWXXhmnolquAIisj6UYnELpxHiZ5VWMYCZszB3xFW2xa8Ab7A1Qi+bDdYG/T 9+XioatJY3LnShI7fZSjzH8PaS6tEfeIKaQ88zdD5ATGuMNlplFaGZBp6u9k9XFdkc4WJq x91tR2qOe0m2aqdgulUlLyUVQj6UdtbV5kF9WQHf+pAjEK6SUvGvOtN1D6xgbg== To: Content-Transfer-Encoding: quoted-printable Subject: [PATCH v3 2/3] migration/rdma: Post initial receive before accepting Date: Sun, 23 Aug 2026 10:16:56 +0800 X-Lms-Return-Path: X-Original-From: Yanfei Xu Cc: , , , , , "Yanfei Xu" From: "Yanfei Xu" Message-Id: <20260823021657.2824542-3-yanfei.xu@bytedance.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20260823021657.2824542-1-yanfei.xu@bytedance.com> References: <20260823021657.2824542-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.115; envelope-from=yanfei.xu@bytedance.com; helo=va-1-115.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: 1787451511773158500 Content-Type: text/plain; charset="utf-8" The source return-path thread can send READY before the destination has posted its initial receive. Since RNR retries default to zero, the send can fail and abort migration. Post the initial receive before rdma_accept() to close this window. Adding delays can easily reproduce it. For exmaple with sleep(1), error could be found at the source side: 2026-08-20T05:55:11.471421Z qemu_rdma_exchange_get_response_start CONTROL: = READY receiving... 2026-08-20T05:55:11.471422Z qemu_rdma_post_send_control CONTROL: sending QE= MU FILE.. 2026-08-20T05:55:11.471447Z qemu_rdma_poll_other other completion 2000 rece= ived left 0 2026-08-20T05:55:11.471589Z qemu_rdma_poll_recv completion 0 received (4000= ) left 0 2026-08-20T05:55:11.471592Z qemu_rdma_poll_other other completion 4000 rece= ived left 0 2026-08-20T05:55:11.471594Z qemu_rdma_exchange_get_response_start CONTROL: = READY receiving... 2026-08-20T05:55:11.471596Z qemu_rdma_post_send_control CONTROL: sending QE= MU FILE.. 2026-08-20T05:55:11.471617Z qemu_rdma_poll_other other completion 2000 rece= ived left 0 2026-08-20T05:55:11.705561Z qemu_rdma_close 2026-08-20T05:55:11.705587Z qemu_rdma_close 2026-08-20T05:55:11.705626Z qemu-system-x86_64: rdma migration: send pollin= g control error 2026-08-20T05:55:11.707001Z qemu-system-x86_64: warning: Early error. Sendi= ng error. 2026-08-20T05:55:11.707031Z qemu_rdma_post_send_control CONTROL: sending ER= ROR.. 2026-08-20T05:55:11.707038Z qemu-system-x86_64: warning: rdma migration: se= nd polling control error 2026-08-20T05:55:11.707301Z qemu_rdma_cleanup_disconnect 2026-08-20T05:55:11.710569Z qemu_rdma_cleanup_disconnect Fixes: 55cc1b5937a8 ("migration: create a dedicated connection for rdma ret= urn path") Signed-off-by: Yanfei Xu Reviewed-by: Peter Xu Reviewed-by: Jack Wang --- migration/rdma.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index fc6cb75167..b79f4263f7 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3274,6 +3274,12 @@ static int qemu_rdma_accept(RDMAContext *rdma) } } =20 + ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY, &err); + if (ret < 0) { + error_report_err(err); + goto err_rdma_dest_wait; + } + /* Accept the second connection request for return path */ if ((migrate_postcopy() || migrate_return_path()) && !rdma->is_return_path) { @@ -3306,12 +3312,6 @@ static int qemu_rdma_accept(RDMAContext *rdma) rdma_ack_cm_event(cm_event); rdma->connected =3D true; =20 - ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY, &err); - if (ret < 0) { - error_report_err(err); - goto err_rdma_dest_wait; - } - qemu_rdma_dump_gid("dest_connect", rdma->cm_id); =20 return 0; --=20 2.20.1 From nobody Sat Sep 26 23:05:15 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=1787451515; cv=none; d=zohomail.com; s=zohoarc; b=DKcDozZ2xYik7RvCmoW3VjeBDjfnfT3y9XCJQbEc7JBLebDaigyrkKn9nQISd3zDwMFhsmbvgV97KTR8LZ+AUKiO78ED2ZBD9Oeu825eza1HifNg5eAhVMCzwLEOhEx08g/RJkBObAy8dT8TJfo7Z59VwWKFMA92tDpOMW54d1o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787451515; 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=3XyZn8SPrma2mrf3YR7O/4EDaLaMGcriT2ELVE2FCs0=; b=jJkgY+yM2xt5wasTOReZNyOebdPcFkMhMGiVnla+SYXGD3MwPhJFk6lwvADKBSAhUhubV+mQBgXzrj7a78uKJH9OPrBoiv4YxdhYi6PqfHGJtXX60qYUHCWDVY3LkOZsgFtsTWvqWg0o6rVSMLxkyKKwBpo0fbte/M97SUHq7aw= 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 1787451515489414.4905399067368; Sat, 22 Aug 2026 19:18:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wxxmt-0004XC-En; Sat, 22 Aug 2026 22:18:21 -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 1wxxmo-0004WY-Li for qemu-devel@nongnu.org; Sat, 22 Aug 2026 22:18:14 -0400 Received: from va-1-115.ptr.blmpb.com ([209.127.230.115]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wxxmm-0005Ni-NC for qemu-devel@nongnu.org; Sat, 22 Aug 2026 22:18:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1787451487; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=3XyZn8SPrma2mrf3YR7O/4EDaLaMGcriT2ELVE2FCs0=; b=gcxdHxIipLzaLWJqiwEV+ZEQ57qADmPt1Sf/6KRYq4YZUaTopGpuLSqcZgRpIAPVMuZfMx ttyTungkXPVgEtWCKrUNihxSO5oXeiSFshjVlZMEhRpcyoMHpM4vWR1wNq8TsRNmwj7slj mJOvOEwRr5Ht+FckwxBa4JjiRBCHbCVPcEoJJhSVQywiNf81Kt2sVgf6czzRWDWIO4cMW6 MY6m+xfRjIn2K8syIhqz6KoVtE9KuyuOHkMTF0gs23XqwSUfCY776iKXtrfIeYODf6+EcX 0/GgYV16KiaQ5oQX1EgxSlJykevq25KTnWYQGPN3+vQySCoQ0NgliQNZuhpYvQ== To: Date: Sun, 23 Aug 2026 10:16:57 +0800 X-Mailer: git-send-email 2.20.1 X-Original-From: Yanfei Xu Subject: [PATCH v3 3/3] migration/rdma: Retry control sends on full queue References: <20260823021657.2824542-1-yanfei.xu@bytedance.com> X-Lms-Return-Path: Message-Id: <20260823021657.2824542-4-yanfei.xu@bytedance.com> Mime-Version: 1.0 Cc: , , , , , "Yanfei Xu" From: "Yanfei Xu" Content-Transfer-Encoding: quoted-printable In-Reply-To: <20260823021657.2824542-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.115; envelope-from=yanfei.xu@bytedance.com; helo=va-1-115.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: 1787451516847158500 Content-Type: text/plain; charset="utf-8" RAM writes and control messages share the send queue. If outstanding writes fill it, RDMA writes drain a completion and retry, but control sends fail the migration. Move send posting and queue-full handling into a common helper. On ENOMEM, drain one outstanding RDMA write and retry the failed request once. If no write is outstanding, or the retry still fails, propagate the error. Signed-off-by: Yanfei Xu Reviewed-by: Peter Xu Reviewed-by: Jack Wang --- migration/rdma.c | 75 ++++++++++++++++++++++++++---------------- migration/trace-events | 2 +- 2 files changed, 48 insertions(+), 29 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index b79f4263f7..b7580ab54f 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1553,6 +1553,51 @@ err_block_for_wrid: return -1; } =20 +/* + * Post a send work request, draining an outstanding RDMA write if the send + * queue is full. + */ +static bool qemu_rdma_post_send(RDMAContext *rdma, + struct ibv_send_wr *send_wr, + Error **errp) +{ + struct ibv_send_wr *bad_wr; + uint64_t wr_id =3D send_wr->wr_id & RDMA_WRID_TYPE_MASK; + const char *wr_desc; + int ret; + + switch (wr_id) { + case RDMA_WRID_RDMA_WRITE: + wr_desc =3D "RDMA write"; + break; + case RDMA_WRID_SEND_CONTROL: + wr_desc =3D "control send"; + break; + default: + g_assert_not_reached(); + } + + ret =3D ibv_post_send(rdma->qp, send_wr, &bad_wr); + if (ret =3D=3D ENOMEM && rdma->nb_sent) { + trace_qemu_rdma_post_send_queue_full(send_wr->wr_id, rdma->nb_sent= ); + ret =3D qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL); + if (ret < 0) { + error_setg(errp, "rdma migration: failed to make room for %s", + wr_desc); + return false; + } + ret =3D ibv_post_send(rdma->qp, send_wr, &bad_wr); + } + + if (ret > 0) { + error_setg_errno(errp, ret, "rdma migration: post %s failed", + wr_desc); + return false; + } + + return true; +} + /* * Post a SEND message work request for the control channel * containing some data and block until the post completes. @@ -1563,7 +1608,6 @@ static int qemu_rdma_post_send_control(RDMAContext *r= dma, uint8_t *buf, { int ret; RDMAWorkRequestData *wr =3D &rdma->wr_data[RDMA_WRID_CONTROL]; - struct ibv_send_wr *bad_wr; struct ibv_sge sge =3D { .addr =3D (uintptr_t)(wr->control), .length =3D head->len + sizeof(RDMAControlHeade= r), @@ -1595,11 +1639,7 @@ static int qemu_rdma_post_send_control(RDMAContext *= rdma, uint8_t *buf, memcpy(wr->control + sizeof(RDMAControlHeader), buf, head->len); } =20 - - ret =3D ibv_post_send(rdma->qp, &send_wr, &bad_wr); - - if (ret > 0) { - error_setg(errp, "Failed to use post IB SEND for control"); + if (!qemu_rdma_post_send(rdma, &send_wr, errp)) { return -1; } =20 @@ -1859,7 +1899,6 @@ 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; uint64_t chunk, chunks; uint64_t chunk_size =3D migrate_rdma_chunk_size(); @@ -1873,7 +1912,6 @@ static int qemu_rdma_write_one(RDMAContext *rdma, .repeat =3D 1, }; =20 -retry: sge.addr =3D (uintptr_t)(block->local_host_addr + (current_addr - block->offset)); sge.length =3D length; @@ -2026,26 +2064,7 @@ retry: trace_qemu_rdma_write_one_post(chunk, sge.addr, send_wr.wr.rdma.remote= _addr, sge.length); =20 - /* - * ibv_post_send() does not return negative error numbers, - * per the specification they are positive - no idea why. - */ - ret =3D ibv_post_send(rdma->qp, &send_wr, &bad_wr); - - if (ret =3D=3D ENOMEM) { - trace_qemu_rdma_write_one_queue_full(); - ret =3D qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL); - if (ret < 0) { - error_setg(errp, "rdma migration: failed to make " - "room in full send queue!"); - return -1; - } - - goto retry; - - } else if (ret > 0) { - error_setg_errno(errp, ret, - "rdma migration: post rdma write failed"); + if (!qemu_rdma_post_send(rdma, &send_wr, errp)) { return -1; } =20 diff --git a/migration/trace-events b/migration/trace-events index bcc102e323..7197c9dc6d 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -250,7 +250,7 @@ qemu_rdma_unregister_waiting_send(uint64_t chunk) "Send= ing unregister for chunk: qemu_rdma_unregister_waiting_complete(uint64_t chunk) "Unregister for chun= k: %" PRIu64 " complete." qemu_rdma_write_flush(int sent) "sent total: %d" qemu_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 -qemu_rdma_write_one_queue_full(void) "" +qemu_rdma_post_send_queue_full(uint64_t wr_id, int sent) "send queue full,= wr_id=3D%" PRIu64 ", outstanding writes=3D%d" qemu_rdma_write_one_recvregres(int mykey, int theirkey, uint64_t chunk) "R= eceived registration result: my key: 0x%x their key 0x%x, chunk %" PRIu64 qemu_rdma_write_one_sendreg(uint64_t chunk, int len, int index, int64_t of= fset) "Sending registration request chunk %" PRIu64 " for %d bytes, index: = %d, offset: %" PRId64 qemu_rdma_write_one_top(uint64_t chunks, uint64_t size) "Writing %" PRIu64= " chunks, (%" PRIu64 " MB)" --=20 2.20.1