Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: ermenson.sec@gmail.com
Cc: alibuda@linux.alibaba.com, dust.li@linux.alibaba.com,
	sidraya@linux.ibm.com, mjambigi@linux.ibm.com,
	tonylu@linux.alibaba.com, guwen@linux.alibaba.com,
	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,
	linux-s390@vger.kernel.org
Subject: Re: [PATCH net-next v2 1/4] net/smc: bound the SMC-Rv1 add-link rkey exchange
Date: Fri, 04 Dec 2026 15:41:51 +0000	[thread overview]
Message-ID: <179639891135.3146.7633707286604525482@kernel.org> (raw)
In-Reply-To: <20261203153514.1440337-2-ermenson.sec@gmail.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message says "Neither check rejects a message a
  conforming peer can send." That holds for the round cap but not for…
- [Low] The new overall deadline (SMC_LLC_RKEY_EXCHG_TIME) is only
  checked at the top of each round.

--

net/smc: bound the SMC-Rv1 add-link rkey exchange

This commit limits the SMC-Rv1 ADD_LINK_CONT rkey exchange loops in
smc_llc_cli_rkey_exchange() and smc_llc_srv_rkey_exchange() to
SMC_LLC_RKEY_CONT_MSG_MAX (128) rounds. It also adds an overall deadline,
SMC_LLC_RKEY_EXCHG_TIME. A peer that keeps reporting num_rkeys=255 can no
longer keep the loop running forever.

> Cap the rounds at that derived limit and give
> the exchange as a whole a deadline: the round cap on its own would
> still allow 128 * SMC_LLC_WAIT_TIME of held mutex, and a deadline on
> its own would still allow an unbounded number of instant rounds under
> it. Neither check rejects a message a conforming peer can send.

[Severity: Low]
Is the last sentence accurate for the deadline? The round cap comes from
the protocol. SMC_LLC_RKEY_EXCHG_TIME is a fixed (SMC_LLC_WAIT_TIME * 10),
which is 20 seconds no matter how many rkeys need to be exchanged.

Before this patch, a peer only had to answer each ADD_LINK_CONT within
SMC_LLC_WAIT_TIME. A full 128 round exchange could therefore legitimately
take up to about 256 seconds.

Both smc_llc_cli_rkey_exchange() and smc_llc_srv_rkey_exchange() now run
this check at the top of each round:

	timeo = (long)(expire - jiffies);
	if (timeo <= 0) {
		rc = -ETIMEDOUT;
		...
	}

A peer can answer every message within 2 seconds and still be aborted, if
its replies average more than about 156 ms per round over 128 rounds.

Slow rounds can have several causes:

  - the peer blocks in smc_wr_tx_get_free_slot(), for up to
    SMC_WR_TX_WAIT_FREE_SLOT_TIME
  - workqueue latency
  - a non-Linux SMC-Rv1 implementation

Nothing is logged when this happens. smc_llc_cli_add_link() sets rc = 0
and goes to out_clear_lnk. smc_llc_srv_add_link() goes to out_err. In both
cases the link group quietly runs without its second link.

Could the commit message say that the deadline can reject a slow but
conforming peer? Or could the deadline be derived from the number of
rounds instead?

> diff --git a/net/smc/smc_llc.c b/net/smc/smc_llc.c
> index c9ccd8480369c..818dd84e720fc 100644
> --- a/net/smc/smc_llc.c
> +++ b/net/smc/smc_llc.c

[ ... ]

> @@ -1359,11 +1384,25 @@ static int smc_llc_srv_rkey_exchange(struct smc_link *link,
>  	down_write(&lgr->rmbs_lock);
>  	num_rkeys_send = lgr->conns_num;
>  	buf_pos = smc_llc_get_first_rmb(lgr, &buf_lst);
> +	expire = jiffies + SMC_LLC_RKEY_EXCHG_TIME;
>  	do {
> +		long timeo;
> +
> +		if (rounds++ >= SMC_LLC_RKEY_CONT_MSG_MAX) {
> +			rc = -EPROTO;
> +			goto out;
> +		}
> +		timeo = (long)(expire - jiffies);
> +		if (timeo <= 0) {
> +			rc = -ETIMEDOUT;
> +			goto out;
> +		}
> +		if (timeo > SMC_LLC_WAIT_TIME)
> +			timeo = SMC_LLC_WAIT_TIME;
> +
>  		smc_llc_add_link_cont(link, link_new, &num_rkeys_send,
>  				      &buf_lst, &buf_pos);
> -		qentry = smc_llc_wait(lgr, link, SMC_LLC_WAIT_TIME,
> -				      SMC_LLC_ADD_LINK_CONT);
> +		qentry = smc_llc_wait(lgr, link, timeo, SMC_LLC_ADD_LINK_CONT);

[Severity: Low]
Can the exchange run past SMC_LLC_RKEY_EXCHG_TIME here? timeo is
computed and capped before smc_llc_add_link_cont(), then passed unchanged
to smc_llc_wait().

smc_llc_add_link_cont() can sleep:

smc_llc_add_link_cont()
  smc_llc_add_pending_send()
    smc_wr_tx_get_free_slot()
      wait_event_interruptible_timeout(link->wr_tx_wait, ...,
                                       SMC_WR_TX_WAIT_FREE_SLOT_TIME);

SMC_WR_TX_WAIT_FREE_SLOT_TIME is 10 * HZ. This wait can happen when all TX
slots are busy, for example when the peer delays completions.

Say a round starts with R jiffies left. It can block for up to 10 seconds
in the send, then still wait up to min(R, SMC_LLC_WAIT_TIME) for the
reply. The exchange can therefore end about 10 seconds past the deadline.
That is also how much longer rmbs_lock, llc_conf_mutex and
smc_server_lgr_pending can stay held.

The later patch in this series, "net/smc: check the ADD_LINK_CONT send
result in the server rkey exchange", only adds a return value check after
the send. It does not recompute timeo, so the overrun is still there at
the end of the series.

The client loop has a similar but smaller overrun. In
smc_llc_cli_rkey_exchange(), the send is the last step of a round, after
the deadline-checked wait:

		smc_llc_flow_qentry_del(&lgr->llc_flow_lcl);
		rc = smc_llc_add_link_cont(link, link_new, &num_rkeys_send,
					   &buf_lst, &buf_pos);
		if (rc)
			break;
	} while (num_rkeys_send || num_rkeys_recv);

A send that blocks after the last wait can also run up to 10 seconds past
the deadline.

Would it work to compute timeo after smc_llc_add_link_cont() returns,
just before smc_llc_wait(), and abort if it is <= 0? Otherwise, the
comment on SMC_LLC_RKEY_EXCHG_TIME and the commit message could call the
deadline approximate.

>  		if (!qentry) {
>  			rc = -ETIMEDOUT;
>  			goto out;

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203153514.1440337-1-ermenson.sec%40gmail.com

  reply	other threads:[~2026-12-04 15:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 15:35 [PATCH net-next v2 0/4] net/smc: stop a silent peer stalling every server handshake Ermenson Junior
2026-12-03 15:35 ` [PATCH net-next v2 1/4] net/smc: bound the SMC-Rv1 add-link rkey exchange Ermenson Junior
2026-12-04 15:41   ` netdev-bot+sashiko [this message]
2026-12-03 15:35 ` [PATCH net-next v2 2/4] net/smc: check the ADD_LINK_CONT send result in the server " Ermenson Junior
2026-12-04 15:41   ` netdev-bot+sashiko
2026-12-03 15:35 ` [PATCH net-next v2 3/4] net/smc: set a new link's peer gid and mac at creation Ermenson Junior
2026-12-04 15:41   ` netdev-bot+sashiko
2026-12-03 15:35 ` [PATCH net-next v2 4/4] net/smc: drop smc_server_lgr_pending across the CLC CONFIRM wait Ermenson Junior
2026-12-04 15:41   ` netdev-bot+sashiko

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=179639891135.3146.7633707286604525482@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alibuda@linux.alibaba.com \
    --cc=davem@davemloft.net \
    --cc=dust.li@linux.alibaba.com \
    --cc=edumazet@kernel.org \
    --cc=ermenson.sec@gmail.com \
    --cc=guwen@linux.alibaba.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mjambigi@linux.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sidraya@linux.ibm.com \
    --cc=tonylu@linux.alibaba.com \
    --cc=willemb@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