From: Piyus Kedia <piyus@iiitd.ac.in>
To: wenjia@linux.ibm.com, jaka@linux.ibm.com,
alibuda@linux.alibaba.com, tonylu@linux.alibaba.com,
guwen@linux.alibaba.com
Cc: netdev@vger.kernel.org, linux-s390@vger.kernel.org,
linux-kernel@vger.kernel.org, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
horms@kernel.org, kapil@presceralabs.ai, stable@vger.kernel.org,
sashiko-reviews@lists.linux.dev
Subject: Re: [PATCH net v3] net/smc: bound the DMB-nocopy send-buffer credit by what was sent
Date: Thu, 26 Nov 2026 20:36:25 +0530 [thread overview]
Message-ID: <20261126150625.2113302-1-piyus@iiitd.ac.in> (raw)
In-Reply-To: <sashiko-outbox-233892@kernel.org>
Thank you - the finding is right on both halves, and the remedy is the one
you name. v4 is posted separately.
[Medium] torn cursor read and non-atomic update in
smc_cdc_msg_recv_action()
Confirmed. smc_curs_diff() reads wrap and count with plain loads:
if (old->wrap != new->wrap)
return max_t(int, 0, ((size - old->count) + new->count));
and this path runs in a tasklet under bh_lock_sock(), which does not
exclude smc_tx_rdma_writes() advancing conn->tx_curs_sent under
conn->send_lock. So passing &conn->tx_curs_sent in place can pair a
pre-wrap wrap with a post-wrap count, exactly as your interleaving shows.
Both outcomes you describe follow: the difference collapses to zero and
the credit is lost after local_rx_ctrl.cons has already moved, or it
exceeds sndbuf_desc->len and the bound does nothing.
The second half is right as well. smc_curs_add() is
curs->count += value;
if (curs->count >= size) {
curs->wrap++;
curs->count -= size;
}
so in place it sets count and then wrap with plain stores and transiently
leaves count >= sndbuf_desc->len, where the code it replaced wrote the
cursor with a single atomic64 store through smc_curs_copy().
v4 does what you suggest, and what smc_tx_prepared_sends() already does
here: it snapshots both cursors with smc_curs_copy(), computes both
differences from the snapshots, advances the local copy of tx_curs_fin and
writes it back with smc_curs_copy(). The cursor update is one atomic
64-bit write again and neither read can tear.
One note for the record: the torn read is not only in the line v3 added.
The diff_tx computation read &conn->tx_curs_fin in place before this
series, and the snapshot closes that too.
What is bounded, and the bound itself, are unchanged from v3.
Tested on 7.3.1 with KASAN; net/smc/smc_cdc.o builds clean at W=1.
pw-bot: cr
next parent reply other threads:[~2026-11-26 15:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <sashiko-outbox-233892@kernel.org>
2026-11-26 15:06 ` Piyus Kedia [this message]
2026-11-24 18:02 Piyus Kedia
2026-11-28 18:17 ` 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=20261126150625.2113302-1-piyus@iiitd.ac.in \
--to=piyus@iiitd.ac.in \
--cc=alibuda@linux.alibaba.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=guwen@linux.alibaba.com \
--cc=horms@kernel.org \
--cc=jaka@linux.ibm.com \
--cc=kapil@presceralabs.ai \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=tonylu@linux.alibaba.com \
--cc=wenjia@linux.ibm.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
all inboxes | Powered by JetHome®