Skip to content

Commit e7bed88

Browse files
lrq-maxdavem330
authored andcommitted
net/smc: remove unneeded atomic operations in smc_tx_sndbuf_nonempty
The commit dcd2cf5 ("net/smc: add autocorking support") adds an atomic variable tx_pushing in smc_connection to make sure only one can send to let it cork more and save CDC slot. since smc_tx_pending can be called in the soft IRQ without checking sock_owned_by_user() at that time, which would cause a race condition because bh_lock_sock() did not honor sock_lock() After commit 6b88af8 ("net/smc: don't send in the BH context if sock_owned_by_user"), the transmission is deferred to when sock_lock() is held by the user. Therefore, we no longer need tx_pending to hold message. So remove atomic variable tx_pushing and its operation, and smc_tx_sndbuf_nonempty becomes a wrapper of __smc_tx_sndbuf_nonempty, so rename __smc_tx_sndbuf_nonempty back to smc_tx_sndbuf_nonempty Suggested-by: Alexandra Winter <wintera@linux.ibm.com> Co-developed-by: Dust Li <dust.li@linux.alibaba.com> Signed-off-by: Dust Li <dust.li@linux.alibaba.com> Signed-off-by: Li RongQing <lirongqing@baidu.com> Reviewed-by: Alexandra Winter <wintera@linux.ibm.com> diff v4: remove atomic variable tx_pushing diff v3: improvements in the commit body and comments diff v2: fix a typo in commit body and add net-next subject-prefix net/smc/smc.h | 1 - net/smc/smc_tx.c | 30 +----------------------------- 2 files changed, 1 insertion(+), 30 deletions(-) Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8e37079 commit e7bed88

File tree

2 files changed

+1
-30
lines changed

2 files changed

+1
-30
lines changed

net/smc/smc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ struct smc_connection {
196196
* - dec on polled tx cqe
197197
*/
198198
wait_queue_head_t cdc_pend_tx_wq; /* wakeup on no cdc_pend_tx_wr*/
199-
atomic_t tx_pushing; /* nr_threads trying tx push */
200199
struct delayed_work tx_work; /* retry of smc_cdc_msg_send */
201200
u32 tx_off; /* base offset in peer rmb */
202201

net/smc/smc_tx.c

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ static int smcd_tx_sndbuf_nonempty(struct smc_connection *conn)
621621
return rc;
622622
}
623623

624-
static int __smc_tx_sndbuf_nonempty(struct smc_connection *conn)
624+
int smc_tx_sndbuf_nonempty(struct smc_connection *conn)
625625
{
626626
struct smc_sock *smc = container_of(conn, struct smc_sock, conn);
627627
int rc = 0;
@@ -655,34 +655,6 @@ static int __smc_tx_sndbuf_nonempty(struct smc_connection *conn)
655655
return rc;
656656
}
657657

658-
int smc_tx_sndbuf_nonempty(struct smc_connection *conn)
659-
{
660-
int rc;
661-
662-
/* This make sure only one can send simultaneously to prevent wasting
663-
* of CPU and CDC slot.
664-
* Record whether someone has tried to push while we are pushing.
665-
*/
666-
if (atomic_inc_return(&conn->tx_pushing) > 1)
667-
return 0;
668-
669-
again:
670-
atomic_set(&conn->tx_pushing, 1);
671-
smp_wmb(); /* Make sure tx_pushing is 1 before real send */
672-
rc = __smc_tx_sndbuf_nonempty(conn);
673-
674-
/* We need to check whether someone else have added some data into
675-
* the send queue and tried to push but failed after the atomic_set()
676-
* when we are pushing.
677-
* If so, we need to push again to prevent those data hang in the send
678-
* queue.
679-
*/
680-
if (unlikely(!atomic_dec_and_test(&conn->tx_pushing)))
681-
goto again;
682-
683-
return rc;
684-
}
685-
686658
/* Wakeup sndbuf consumers from process context
687659
* since there is more data to transmit. The caller
688660
* must hold sock lock.

0 commit comments

Comments
 (0)