Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Piyus Kedia
Thu, 26 Nov 2026 15:06
Re: [PATCH net v3] net/smc: bound the DMB-nocopy send-buffer credit by what was sent
Author: Piyus Kedia
Date: Thu, 26 Nov 2026 15:06
Date: Thu, 26 Nov 2026 15:06
47 lines
12275 bytes
12275 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads