Netdev List
 help / color / mirror / Atom feed
From: Allison Henderson <achender@kernel.org>
To: Zhenwen Liang <zhenwenliang@google.com>
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
Subject: Re: [PATCH net v2] net/rds: wake the shutdown waiter after returning the FRWR slot
Date: Fri, 04 Dec 2026 20:07:52 -0700	[thread overview]
Message-ID: <799ed917cfdc44e115e5137505950b74348aebb1.camel@kernel.org> (raw)
In-Reply-To: <20261202172415.2785749-1-zhenwenliang@google.com>

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.
> 
> Wake the waiter after the slot is returned instead, using
> wq_has_sleeper() so that the increment is ordered before the wait queue
> check.
> 
> 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.
> 
> Fixes: 3a2886cca703 ("net/rds: Keep track of and wait for FRWR segments in use upon shutdown")
> Suggested-by: Allison Henderson <achender@kernel.org>
> Signed-off-by: Zhenwen Liang <zhenwenliang@google.com>

Hi Zhenwen, 

v2 looks good to me, thanks for working on this!
Reviewed-by: Allison Henderson <achender@kernel.org>

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).
> 
>  net/rds/ib_frmr.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
> 
> 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);
>  	}
>  }
>  
> +/* Return an i_fastreg_wrs slot and wake rds_ib_conn_path_shutdown(), which
> + * 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_ibdev,
>  					   int npages)
>  {
> @@ -184,7 +192,7 @@ static int rds_ib_post_reg_frmr(struct rds_ib_mr *ibmr)
>  	return ret;
>  
>  out_inc:
> -	atomic_inc(&ibmr->ic->i_fastreg_wrs);
> +	rds_ib_put_fastreg_wr(ibmr->ic);
>  	return ret;
>  }
>  
> @@ -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);
>  }
>  
>  void rds_ib_unreg_frmr(struct list_head *list, unsigned int *nfreed,


      reply	other threads:[~2026-12-05  3:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 17:24 [PATCH net v2] net/rds: wake the shutdown waiter after returning the FRWR slot Zhenwen Liang
2026-12-05  3:07 ` Allison Henderson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=799ed917cfdc44e115e5137505950b74348aebb1.camel@kernel.org \
    --to=achender@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rds-devel@oss.oracle.com \
    --cc=willemb@google.com \
    --cc=zhenwenliang@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox