From: sashiko-bot@kernel.org
To: "Piyus Kedia" <piyus@iiitd.ac.in>
Cc: linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org,
"Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: Re: [PATCH net v2 2/2] net/smc: bound the DMB-nocopy send-buffer credit as well
Date: Tue, 24 Nov 2026 13:53:44 +0000 [thread overview]
Message-ID: <sashiko-outbox-231271@kernel.org> (raw)
In-Reply-To: <20261123135327.3953509-2-piyus@iiitd.ac.in>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] net/smc: smc_cdc_msg_recv_action() bounds diff_tx by prepared
not sent bytes
- [Medium] net/smc: smc_cdc_msg_recv_action() leaves local_rx_ctrl.cons
unclamped
--
commit 07f52f148d1ba914d6b4ce3e90b172be0a15f763
Author: Piyus Kedia <piyus@iiitd.ac.in>
net/smc: bound the DMB-nocopy send-buffer credit as well
This commit bounds the send-buffer credit on the SMC-D DMB-nocopy path in
smc_cdc_msg_recv_action() by the amount of data outstanding in the send
buffer and advances tx_curs_fin by the bounded amount.
Link: https://lore.kernel.org/all/20261122053223.2497832-2-piyus@iiitd.ac.in/
> diff --git a/net/smc/smc_cdc.c b/net/smc/smc_cdc.c
> index 32d6d03df3214..9ffa3e422aa1f 100644
> --- a/net/smc/smc_cdc.c
> +++ b/net/smc/smc_cdc.c
> @@ -333,6 +333,7 @@ static void smc_cdc_msg_recv_action(struct smc_sock *smc,
> union smc_host_cursor cons_old, prod_old;
> struct smc_connection *conn = &smc->conn;
> int diff_cons, diff_prod, diff_tx;
> + int sent;
>
> smc_curs_copy(&prod_old, &conn->local_rx_ctrl.prod, conn);
> smc_curs_copy(&cons_old, &conn->local_rx_ctrl.cons, conn);
> @@ -361,13 +362,26 @@ static void smc_cdc_msg_recv_action(struct smc_sock *smc,
> diff_tx = smc_curs_diff(conn->sndbuf_desc->len,
> &conn->tx_curs_fin,
> &conn->local_rx_ctrl.cons);
> + /* This difference comes from the cursor the peer
> + * reported, which is taken as it arrives. A peer
> + * cannot have consumed more than this side has
> + * outstanding, so bound it by that and advance
> + * tx_curs_fin by the bounded amount rather than
> + * assigning the reported cursor: the invariant below
> + * then holds by construction, and tx_curs_fin stays
> + * inside the send buffer.
> + */
> + sent = conn->sndbuf_desc->len -
> + atomic_read(&conn->sndbuf_space);
> + diff_tx = min_t(int, diff_tx, max_t(int, sent, 0));
[Severity: Medium]
Can bounding diff_tx by conn->sndbuf_desc->len - sndbuf_space still advance
conn->tx_curs_fin past conn->tx_curs_sent and credit sndbuf_space for
prepared data that has not been sent yet?
smc_tx_sendmsg() advances conn->tx_curs_prep and subtracts copylen from
conn->sndbuf_space as soon as data is copied into the send buffer, before
smc_tx_sndbuf_nonempty() advances conn->tx_curs_sent (which is skipped when
corked via MSG_MORE or TCP_CORK). When prepared-but-unsent bytes exist,
conn->sndbuf_desc->len - sndbuf_space includes [tx_curs_sent, tx_curs_prep),
so a peer consumer cursor ahead of tx_curs_sent pushes tx_curs_fin past
tx_curs_sent and allows subsequent smc_tx_sendmsg() calls to overwrite the
unsent bytes. Should sent be computed with smc_curs_diff() between
conn->tx_curs_fin and conn->tx_curs_sent, as smcd_cdc_msg_send() does?
> /* increase local sndbuf space and fin_curs */
> smp_mb__before_atomic();
> atomic_add(diff_tx, &conn->sndbuf_space);
> /* guarantee 0 <= sndbuf_space <= sndbuf_desc->len */
> smp_mb__after_atomic();
> - smc_curs_copy(&conn->tx_curs_fin,
> - &conn->local_rx_ctrl.cons, conn);
> + smc_curs_add(conn->sndbuf_desc->len,
> + &conn->tx_curs_fin, diff_tx);
[Severity: Medium]
Does advancing conn->tx_curs_fin by the clamped diff_tx while leaving
conn->local_rx_ctrl.cons at the peer's raw cursor desynchronize the two
cursors for subsequent CDC messages?
smc_cdc_msg_to_host() has already written the unclamped cursor into
conn->local_rx_ctrl.cons. Once diff_tx is clamped, local_rx_ctrl.cons sits
ahead of tx_curs_fin: if more data is sent and the peer advances its forged
cursor by 1 byte, diff_cons is 1 and smc_cdc_msg_recv_action() recomputes
diff_tx across the entire remaining gap between tx_curs_fin and the forged
local_rx_ctrl.cons, crediting all newly sent bytes at once (whereas a later
valid cursor below the forged cons_old yields diff_cons == 0 and credits
nothing).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123135327.3953509-1-piyus@iiitd.ac.in?part=2
next prev parent reply other threads:[~2026-11-24 13:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 13:53 [PATCH net v2 1/2] net/smc: bound the failover cursor catch-up by what is outstanding Piyus Kedia
2026-11-23 13:53 ` [PATCH net v2 2/2] net/smc: bound the DMB-nocopy send-buffer credit as well Piyus Kedia
2026-11-24 13:53 ` sashiko-bot [this message]
2026-11-24 14:14 ` netdev-bot+sashiko
2026-11-24 18:03 ` Piyus Kedia
2026-11-24 13:53 ` [PATCH net v2 1/2] net/smc: bound the failover cursor catch-up by what is outstanding sashiko-bot
2026-11-24 14:14 ` netdev-bot+sashiko
2026-11-24 17:30 ` Piyus Kedia
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=sashiko-outbox-231271@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=piyus@iiitd.ac.in \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.