From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796143656; b=5ATgQeNK8bTPCkKuT3TjVFVywAESvVeeS58XoG/X4tydLHoMNdEjJhqhHTcGFTiO9SEc xVCpzuKCPUj7q2vokFLIwKPDUZEOHslL4QNLl+kU9il0wgUlcmXYz7/FoOp0jinWUHCzf kox11atHmDu9nmoz6vEl/dQ/Zuzgz9BSW5za1wD29XMTooczOCaKXSOsq/NsiC2GKIiYK f4cMckXc39R64wsnTXGWhVY3acfYdAPnLHVQygHeBvhW6Uo2vk2KhU0iHfznHFp3ztk5W hjaWU0zGzgimUjd5joi5PCzKpL8FdpOxLvoym/w1s47Rv24FMMq7hSpt6E6T62b99ig== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796143656; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=Ays4P/hq9NIntNHcraKBqPRun0KHEPUnDfIvbVVrWpo=; b=oIHz+oIvT0Mgsh7DtRlLZURWREOZW1wNI2DzkI7Tc1D5nLN5tZ1iMCvcopzDw+LWrCID UOnd2j9AseJH5XSl46j5NmQsXpvRqlRRvGfrWCBC9u1CTT7/mavC9EHtlAYtjz8RSfr4J 7aoUKhhNR7GwZDcFQCeUPUR6KUdI2qIx3423tMCjSzQwXOJk1XKbXX2hs1YMEFqTpsxr+ RoWcbkYQlvxvRPglbTqSH8W3QHwuj/CRXOGwzkR6LZdZOiyXjgsz/NzMplqaPHCT85Hdd f9xSKYzTCEMAfBAWe97CDKmaCHvKrHSQovr4rzF2UnFvh7bYx4n7pHpcdFqmnYRgHxA== 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=LbyHWXNq; arc=none smtp.remote-ip=100.103.45.18 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 8634B606A31A; Tue, 1 Dec 2026 16:47:36 +0000 (UTC) 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=LbyHWXNq Received: by smtp.kernel.org (Postfix) with ESMTPSA id 773621F000C1; Tue, 1 Dec 2026 16:47:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796143656; bh=Ays4P/hq9NIntNHcraKBqPRun0KHEPUnDfIvbVVrWpo=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=LbyHWXNqP/RPlipkBJo7zRlmwcTpf67415tPY0O3JwjkgCQJdg6KgbHFvtg1FJBdY VNjfrikIzpJiW+KsLrgnzqWkjkM9w2S2l2rHW7tidqTzOs9eLTntRkLQMVD00Y5JRM cEYXvB6lJQjaAcf2NpjFv6cxbmbKENI5chVrzSREXWoJ3CLMjBCF+gOYp8LBXCDOaR GLThlGtpfm/yN25pn/cMVcqOGgJ1oOjmAjyGnRfLUYemT2mEU2vtfr1sc+M6i80LZq YZ7neFVKXekXkq4rVCuzOqdg/9aED+m44yfkrC/0k/KSzusqHTqNZmYkU1UYISUzNg QnBv9wPHfOLlQ== Subject: Re: [PATCH net] net/rds: use wq_has_sleeper() in rds_transition_frwr_state() From: netdev-bot+sashiko@kernel.org To: zhenwenliang@google.com Cc: achender@kernel.org, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com Date: Tue, 01 Dec 2026 16:47:34 +0000 Message-ID: <179614365498.3146.898864177949613339@kernel.org> In-Reply-To: <20261130164729.981519-1-zhenwenliang@google.com> References: <20261130164729.981519-1-zhenwenliang@google.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider. Critical: 0 · High: 2 · Medium: 0 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] The patch fixes only one of the two unordered wakers of rds_ib_ring_empty_wait. - [High] The wakeup that the patch makes reliable fires before the shutdown wait condition can be true, and nothing wakes the waiter once… -- net/rds: use wq_has_sleeper() in rds_transition_frwr_state() This patch replaces waitqueue_active() with wq_has_sleeper() in rds_transition_frwr_state(). The full barrier then orders the i_fastreg_inuse_count decrement before the wait queue check. The aim is to stop rds_ib_conn_path_shutdown() from missing the wakeup and sleeping until its 1 s timeout on weakly ordered architectures. > diff --git a/net/rds/ib_frmr.c b/net/rds/ib_frmr.c > index 8397aa4a17ac8..9a9424a499a37 100644 > --- a/net/rds/ib_frmr.c > +++ b/net/rds/ib_frmr.c > @@ -45,7 +45,7 @@ rds_transition_frwr_state(struct rds_ib_mr *ibmr, > */ > smp_mb__before_atomic(); > atomic_dec(&ibmr->ic->i_fastreg_inuse_count); > - if (waitqueue_active(&rds_ib_ring_empty_wait)) > + if (wq_has_sleeper(&rds_ib_ring_empty_wait)) > wake_up(&rds_ib_ring_empty_wait); [Severity: High] Is there a second waker of rds_ib_ring_empty_wait with the same missing barrier? rds_ib_ring_free() in net/rds/ib_ring.c does a void atomic RMW and then calls waitqueue_active() with no barrier in between: net/rds/ib_ring.c:rds_ib_ring_free() { ring->w_free_ptr = (ring->w_free_ptr + val) % ring->w_nr; atomic_add(val, &ring->w_free_ctr); if (__rds_ib_ring_empty(ring) && waitqueue_active(&rds_ib_ring_empty_wait)) wake_up(&rds_ib_ring_empty_wait); } It wakes the same waiter, because rds_ib_conn_path_shutdown_check_wait() requires rds_ib_ring_empty(&ic->i_recv_ring). During shutdown, flushed receive WRs go through rds_ib_recv_cqe_handler()->rds_ib_ring_free(). If that is the last event that satisfies the wait condition, the store buffering problem described in the commit message applies here too. The similar fix mentioned in the commit message (commit 6d0c8b707391) changed release_in_xmit() in net/rds/send.c. It did not touch ib_ring.c. rds_ib_sub_signaled() uses atomic_sub_return(), which is fully ordered. That makes rds_ib_ring_free() the only unordered waker left on this wait queue. Should rds_ib_ring_free() also be converted to wq_has_sleeper() in this patch? [Severity: High] Can this wakeup fire before the shutdown condition is able to become true? rds_ib_conn_path_shutdown_check_wait() needs both counters to have settled: (atomic_read(&ic->i_fastreg_inuse_count)) == 0 && (atomic_read(&ic->i_fastreg_wrs) == RDS_IB_DEFAULT_FR_WR) Every FRWR post first takes an i_fastreg_wrs slot with atomic_dec_return(). While the last WR is in flight, i_fastreg_wrs is therefore one below RDS_IB_DEFAULT_FR_WR. On completion, rds_ib_mr_cqe_handler() wakes the waiter through rds_transition_frwr_state(). It only gives the slot back at the end: net/rds/ib_frmr.c:rds_ib_mr_cqe_handler() { ... if (frmr->fr_inv) { rds_transition_frwr_state(ibmr, FRMR_IS_INUSE, FRMR_IS_FREE); frmr->fr_inv = false; wake_up(&frmr->fr_inv_done); } ... smp_mb__before_atomic(); atomic_inc(&ic->i_fastreg_wrs); } Suppose the shutdown thread re-checks between the wake and the atomic_inc(). It sees inuse_count == 0 with i_fastreg_wrs still one short, and goes back to sleep. Nothing wakes rds_ib_ring_empty_wait after the increment, and poll_scq() does not add a wakeup either. The waiter would then sleep until the 1000 ms timeout, on any architecture. The error paths do things in the same order, with wider windows. In rds_ib_post_reg_frmr(), the wake happens when ib_post_send() fails. Then printk_ratelimit()/pr_warn() runs, and i_fastreg_wrs is only restored at out_inc: rds_transition_frwr_state(ibmr, FRMR_IS_INUSE, FRMR_IS_STALE); if (printk_ratelimit()) pr_warn("RDS/IB: %s returned error(%d)\n", __func__, ret); goto out_inc; ... out_inc: atomic_inc(&ibmr->ic->i_fastreg_wrs); Two other paths have the same order: - the ib_post_send() error path in rds_ib_post_inv() - the wc->status != IB_WC_SUCCESS branch of rds_ib_mr_cqe_handler(), which flushed WRs take during disconnect Would it work better to do the wq_has_sleeper()/wake_up() after each atomic_inc(&i_fastreg_wrs), instead of only adding a barrier at this wake site? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130164729.981519-1-zhenwenliang%40google.com