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=1796440074; b=186IgnTcOUwRJ3NErnWmd7eH2KyiEOWhoy4ocDJBNJ5Xrql525CNucEofEMhkhzc08RL 5WohQ9eIIY8O1/d+ai44vTvnvMwFQ55uJ6wbN4u6Vtow3Tf3c2PU480m+/LZaBNvVILzi tIDWm/dGjTRV6OPjhRqsrE7Bz+VlMF93QfQGpjbEOVz7byNBvWzNY0/zACBopfhopho0P IvGmz57IJYwplvvIwtUv16bxtrPO3SXqclgl13f0k2gBp9B1msLLOOgUifGs7mxNAnkQq tDrlYXdJI40R2LK9Xkc3g2DTARCCOurMzHmh9n65D8FZ1rjwQ2Due1M1qxYr2vzeGxw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796440074; 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=GUSXu0itEBE0dyDAyoAeaxGby4zLc/LAHHyvw/TfUYM=; b=Ve56JuCbmn3DGz5zccQjzUty52IdzhljAQVdOCNtzKC16MnBNPxqnERepRZzwzYnzLjV a7DXrLD8RIV8n82RO32a7NKLVRPm+nbzk+NGmPcMYY0mPzWoog76E3aT60okyLLcq8QYk E74xCC+q9FORVR2RJTN1h8NiZanO3j9AV+FZA8mCBfDFZQRQyXGqgnmp2IBxGmenRgfDO ZPTWrVHtDkSRMHU6fYGR7uGQSny0pf7MKWDagxixhyurAZOfMOy8R9ZdgniP6R+sCLDj/ Hrjp//2tKd4KpspstYHoUuc2ARIxu8nXWJ/JXhsYmbVXw3WZZq09wBICLLM/XJ3kyxQ== 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=Yo6CjlEB; 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 1E3A0606A322; Sat, 5 Dec 2026 03:07:54 +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=Yo6CjlEB Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74DF21F00936; Sat, 5 Dec 2026 03:07:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796440073; bh=GUSXu0itEBE0dyDAyoAeaxGby4zLc/LAHHyvw/TfUYM=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Yo6CjlEBTguKhrHuCZXayAsviXIaDDXNWLwEWmtXwMRrvHFhcIOUnjOQXQX0BAdUE 2b2wS0Da565Xxd+f7ecL0QalWavSiz74nFsYEXSzFvKjRVFf1I1hRNjmgiBfMEQvRb N2/bReJ9yFjG3HUdDwM67zU7l6QGPNeNLHwHkBCev1me0QACzFZ8uzspKaz6jBSgoJ vMTpbyqYFpS40FuYXrLG6vmULyy1SC5/lrjWIKFxrb1pbEocD9TWWKbrkJIWZehDsq GpDVrGf/QAieHlEUNfFIrk5kPVmy750+Wbb+SCQG1sRsQWCjdBDP5euo+TYYLxevN3 /t+5jvTQEcQgA== Message-ID: <799ed917cfdc44e115e5137505950b74348aebb1.camel@kernel.org> Subject: Re: [PATCH net v2] net/rds: wake the shutdown waiter after returning the FRWR slot From: Allison Henderson To: Zhenwen Liang Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com Date: Fri, 04 Dec 2026 20:07:52 -0700 In-Reply-To: <20261202172415.2785749-1-zhenwenliang@google.com> References: <20261202172415.2785749-1-zhenwenliang@google.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.3-0ubuntu1.1 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 On Wed, 2026-12-02 at 17:24 +0000, Zhenwen Liang wrote: > rds_ib_conn_path_shutdown() waits until, among other things, > i_fastreg_inuse_count is 0 and i_fastreg_wrs is back at > RDS_IB_DEFAULT_FR_WR. rds_transition_frwr_state() wakes it when it drops > i_fastreg_inuse_count, but every caller still holds an i_fastreg_wrs slot > at that point and returns it later without a wake-up. A waiter that > rechecks in between goes back to sleep, and shutdown waits for its 1 s > timeout on any architecture. >=20 > Wake the waiter after the slot is returned instead, using > wq_has_sleeper() so that the increment is ordered before the wait queue > check. >=20 > Allison Henderson pointed out that the sashiko review of a similar fix > flagged this site. The analysis was checked, 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. >=20 > Fixes: 3a2886cca703 ("net/rds: Keep track of and wait for FRWR segments i= n use upon shutdown") > Suggested-by: Allison Henderson > Signed-off-by: Zhenwen Liang Hi Zhenwen,=20 v2 looks good to me, thanks for working on this! Reviewed-by: Allison Henderson Allison > --- > v2: Wake the waiter after i_fastreg_wrs is incremented, not in > rds_transition_frwr_state(), where the wait condition cannot hold yet > (Sashiko review). New subject. > v1: https://lore.kernel.org/r/20261130164729.981519-1-zhenwenliang@google= .com/ > The other unordered waker, rds_ib_ring_free(), is fixed separately: > https://lore.kernel.org/r/20261129024701.277838-1-zhenwenliang@google.com= / > Compile-tested only (arm64). >=20 > net/rds/ib_frmr.c | 18 +++++++++++++----- > 1 file changed, 13 insertions(+), 5 deletions(-) >=20 > diff --git a/net/rds/ib_frmr.c b/net/rds/ib_frmr.c > index 8397aa4a17ac..b6172d8ca43d 100644 > --- a/net/rds/ib_frmr.c > +++ b/net/rds/ib_frmr.c > @@ -45,11 +45,19 @@ 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)) > - wake_up(&rds_ib_ring_empty_wait); > } > } > =20 > +/* Return an i_fastreg_wrs slot and wake rds_ib_conn_path_shutdown(), wh= ich > + * waits for all slots to be back. > + */ > +static void rds_ib_put_fastreg_wr(struct rds_ib_connection *ic) > +{ > + atomic_inc(&ic->i_fastreg_wrs); > + if (wq_has_sleeper(&rds_ib_ring_empty_wait)) > + wake_up(&rds_ib_ring_empty_wait); > +} > + > static struct rds_ib_mr *rds_ib_alloc_frmr(struct rds_ib_device *rds_ibd= ev, > int npages) > { > @@ -184,7 +192,7 @@ static int rds_ib_post_reg_frmr(struct rds_ib_mr *ibm= r) > return ret; > =20 > out_inc: > - atomic_inc(&ibmr->ic->i_fastreg_wrs); > + rds_ib_put_fastreg_wr(ibmr->ic); > return ret; > } > =20 > @@ -301,7 +309,7 @@ static int rds_ib_post_inv(struct rds_ib_mr *ibmr) > * before incrementing i_fastreg_wrs > */ > smp_mb__before_atomic(); > - atomic_inc(&ibmr->ic->i_fastreg_wrs); > + rds_ib_put_fastreg_wr(ibmr->ic); > pr_err("RDS/IB: %s returned error(%d)\n", __func__, ret); > goto out; > } > @@ -354,7 +362,7 @@ void rds_ib_mr_cqe_handler(struct rds_ib_connection *= ic, struct ib_wc *wc) > * before incrementing i_fastreg_wrs > */ > smp_mb__before_atomic(); > - atomic_inc(&ic->i_fastreg_wrs); > + rds_ib_put_fastreg_wr(ic); > } > =20 > void rds_ib_unreg_frmr(struct list_head *list, unsigned int *nfreed,