Article View: linux.kernel.netdev
Article #24457Re: [PATCH net] net/rds: use wq_has_sleeper() in rds_ib_ring_free()
From: Allison Henderson
Date: Mon, 30 Nov 2026 07:25
Date: Mon, 30 Nov 2026 07:25
79 lines
11353 bytes
11353 bytes
On Sun, 2026-11-29 at 02:47 +0000, Zhenwen Liang wrote:
> rds_ib_ring_free() returns slots to a work ring with atomic_add() and
> then checks waitqueue_active() on rds_ib_ring_empty_wait to decide
> whether anyone needs waking. atomic_add() carries no ordering and
> waitqueue_active() is a plain load, so nothing orders the counter update
> before the wait queue read. The waiter does the mirror image:
> rds_ib_conn_path_shutdown() adds itself to rds_ib_ring_empty_wait in
> wait_event_timeout(), which sets the task state with a full barrier, and
> then checks, among other conditions, whether the receive ring is empty.
> That is the store-buffering pattern described above waitqueue_active()
> in include/linux/wait.h: the waker can observe an empty wait queue while
> the waiter still observes the ring as not empty, and no wakeup is
> issued, so connection shutdown in rds_ib_conn_path_shutdown() stalls: on
> kernels with commit 16f48efaeb69 ("net/rds: Don't sleep inside
> rds_ib_conn_path_shutdown") or its stable backports, the waiter wakes
> after at most about 1 s; on kernels without it, it waits until the next
> wakeup.
>
> Use wq_has_sleeper(), which is waitqueue_active() preceded by the
> required full barrier, as was done for the same pattern in
> commit d4f484661961 ("net/rds: use wq_has_sleeper() in
> rds_cong_map_updated()") and commit 6d0c8b707391 ("net/rds: use
> wq_has_sleeper() in release_in_xmit()"); commit 17c4476dbb9c ("net/rds:
> use clear_bit_unlock() in release_refill()") also switched to
> wq_has_sleeper().
>
> The outcome is allowed by the Linux kernel memory model for a litmus
> test derived from the code, and by the AArch64 and PPC models for a
> litmus test of the same pattern. With smp_mb() added before the wait
> queue check, where wq_has_sleeper() places it, herd7 forbids it (LKMM,
> AArch64 and PPC models).
>
> The problem was found, and this patch prepared, with the help of a
> formal analysis tool we are developing that uses AI assistance; I have
> reviewed the analysis and the patch.
>
> Compile-tested with clang on arm64 and x86-64 with W=1, and checked that
> the barrier is emitted between the atomic_add() and the wait queue load
> in arm64 object code; not runtime-tested.
>
> Fixes: f528efe276ec ("RDS/IB: Ring-handling code.")
> Signed-off-by: Zhenwen Liang <zhenwenliang@google.com>
Thanks Zhenwen, this looks right to me.
Reviewed-by: Allison Henderson <achender@kernel.org>
Also, this patch did have a sashiko review, though I didnt see that it
got mailed out. Mostly it identified a similar issue in
rds_transition_frwr_state(), so a similar fix could apply there too but I
didnt see that it should hold up this patch. If you do decide to address it,
please send a separate patch,
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129024701.277838-1-zhenwenliang%40google.com
Thanks!
Allison
> ---
> net/rds/ib_ring.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/rds/ib_ring.c b/net/rds/ib_ring.c
> index 006b2e441418..4bbd3426b724 100644
> --- a/net/rds/ib_ring.c
> +++ b/net/rds/ib_ring.c
> @@ -120,7 +120,7 @@ void rds_ib_ring_free(struct rds_ib_work_ring *ring, u32 val)
> atomic_add(val, &ring->w_free_ctr);
>
> if (__rds_ib_ring_empty(ring) &&
> - waitqueue_active(&rds_ib_ring_empty_wait))
> + wq_has_sleeper(&rds_ib_ring_empty_wait))
> wake_up(&rds_ib_ring_empty_wait);
> }
>
Technical Details
Message-ID:
<604973ba164734511b6d50e61451032d5a27489a.camel@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373966-linux-kernel-netdev=dewy.ruReferences:
<20261129024701.277838-1-zhenwenliang@google.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373966-linux-kernel-netdev=dewy.ru From: achender@kernel.org (Allison Henderson) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] net/rds: use wq_has_sleeper() in rds_ib_ring_free() Date: Mon, 30 Nov 2026 00:25:45 -0700 Organization: Usenet Network Message-ID: <604973ba164734511b6d50e61451032d5a27489a.camel@kernel.org> References: <20261129024701.277838-1-zhenwenliang@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="1364513"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:84SL/XLt02atojGCdjQVXzo4Foo= sha256:iPdssuF2GYJme7Ek/hDnlc71mya+Q5F7nq/qCv4bcgU= sha1:TgeUYKE//BmzIi7rIeMGXDkdhF8= sha256:EoUs07XpyroSNYTy8DS/BCNZtCVwDIAZnBng3bTeUbs= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id A8774125FC6; Mon, 30 Nov 2026 10:26:05 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pL6jaj1hcWzz; Mon, 30 Nov 2026 10:26:00 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373966-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 73AC8125FC5; Mon, 30 Nov 2026 10:25:51 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id EB0E6295C4; Mon, 30 Nov 2026 07:25:47 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796023547; b=vCYrffDenMTuDzXN6JbC0ix4g9hz4e/zn3CNCVifha+7ukOJacd8zVGi/X0c8o97UA18 uRE62RLJhOmzGVYN093C1Cb5j5UrjwVIB/rOJMuZgIuJR9+ERac42EC7xvZPme+bX7XCX CG2nKixZhzU3OXeyqs/IEfr1OsindM7HvyzXUFXbQ3OU+PE1Xfiy6QIYaOFActxxmkRmA vlMp70LKNpNG+FmBT0FJQ0yLsb22nfUGRRXH6QgP/ga+RkTp6+LRCjvZcPf/V4Ig01LCt od78/58fCmwvNX32t1o6MR6hil/V1EqRmMbZzIcwylGo96S8Do+hXFkS7YbHa3IsDsg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796023547; h=X-Original-To:Received:Received:DKIM-Signature:Message-ID:Subject: From:To:Cc:Date:In-Reply-To:References:Content-Type: Content-Transfer-Encoding:User-Agent:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version; bh=bHuDLuE5qR5TBM4h50nTFYv3JCBapg0gCj/rQE7L5YQ=; b=bZcwEvR2IpoZM8Xmn4E4benLVwtZyCpk6ggCzz/6n+8ghsCP6YZEaofSd4j4nLjZWeUO cFQl7CzbYwdBhzujXVqoo0DhwhWnxbwso3DOj3U75ru90w6SbvI7oSM471jhUeSB0/TUG QZ5+KicttvxLoJe929VO+Q/1aLeBJvJixO3LnQHTGIlmpbK3GnrzAG9kjKXjWbxurC8Nq KDdIHCoA/M4AlZtB7QvCzNCNjRY1boByYjFThdB0vd2jkzwX1h0mxkk7Ls05Wt1OSbgwt +5jBxuRRodzgHz7AGdMSeSO0iBksEk7fEUakBrKuhuuUqIIhzyhC53alqHnBbkxrywQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dKErJyMF; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C327C606A335; Mon, 30 Nov 2026 07:25:47 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dKErJyMF X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796023547; b=GpFtqpA+vmr/8yqcIZHUPPSEqCHzme0qDWXLSZUWdy0MRl0faS/luPjUpcCXGg1+MVuk 7j2E0ciz3E1RtK6abUnbWSOEYDRcDRxMQH3F7MuCKTkXV+VIsraMUf4eEPCJV2KlzrFlR ymgOstoNWAsbLUEj4AGk5CKGumDnGDHMd8v/0KucmOlb10IX2WC01uu6XQFCXkY0NWZtt 9QNu/ohNJ8Y0HkYNiaFtcUPZ5TGstx7W0oFieLcxLq/y0lwvd2O1R6ytfNyJOHzlc/FCK T3Qj3n/wC+bpAFgcOWrkFEIcw8HZZ8HTK2XDBiMIC4wbRHEc4pv6pAUc/PdyzRaKx/Q== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796023547; h=Received:DKIM-Signature:Message-ID:Subject:From:To:Cc:Date: In-Reply-To:References:Content-Type:Content-Transfer-Encoding: User-Agent:MIME-Version; bh=bHuDLuE5qR5TBM4h50nTFYv3JCBapg0gCj/rQE7L5YQ=; b=Ho7pFEYOBXeJkA+HO4ZF0g+kvoZACDTkQCrzHT+7obcGEsRUoQ5EQUCinGAJWMRcsmgi O/7YrkB1VzzEt+7ghtAipr2NzJJXpkUWQNzN+YQYv22rchNWdM12UOMlm1RWhzN5aTQTy QJJypady9KjgrXxqgiBP4l0SpmIYZcVe3+z8OOQEP4LC0n2rfi1vc3upo18sBN2h7oPrv 7kPRFTTT8KOkTB5/X5zJ5PPjNc/qVsfsp7vK7++MtpRnUdYT87f7H05d0LsP+ld3yq3NU 0be5ROnOCHDBvzPQUwnF7ucW/ZHP3cAaQt9wcknRP8MbeI47v2xF79Bhod9m2TUMljQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dKErJyMF; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E23AE606A31C; Mon, 30 Nov 2026 07:25:46 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id E70ED1F0089B; Mon, 30 Nov 2026 07:25:45 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796023546; bh=bHuDLuE5qR5TBM4h50nTFYv3JCBapg0gCj/rQE7L5YQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=dKErJyMF3Z54/JCXAgHK++dpY5gjpH2wQtB7WJTWHAAvdNRK50yCT37oMk8gmAn91 YvpOg6sPSp2h4mB2Icn7CHNgIomGKY38YAtJ9ha6LMKSdu3gOhEN5hdaO1MjUdWMWU 5EqHEYQlvI9iHxZba5WVShRpmr3rRoW99HCU+trq2xER9Rt5NpuGPXSp7ME7dMXd9y s2g8xfvLsAInqKMX38B7R9OTUSMlbZn0sGIcwX5sZvFt0TEY6iya6P/eQ8SfbnYPhr y+vzOCtJGMDHEPTyyOz+vxG2RDz/Zr3nhiq9xlCs2PydttTgsd3iQRhwr+OPxVLog/ q82pjXpK5CZjg== X-Cc: "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Willem de Bruijn <willemb@google.com>, Simon Horman <horms@kernel.org>, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com X-In-Reply-To: <20261129024701.277838-1-zhenwenliang@google.com> X-User-Agent: Evolution 3.52.3-0ubuntu1.1 X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list