Skip to content

Commit b15c8df

Browse files
author
Mete Durlu
committed
net/smc: remove unneeded atomic operations in smc_tx_sndbuf_nonempty
JIRA: https://issues.redhat.com/browse/RHEL-73484 commit e7bed88 Author: Li RongQing <lirongqing@baidu.com> Date: Thu Nov 23 09:45:37 2023 +0800 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> Signed-off-by: Mete Durlu <mdurlu@redhat.com>
1 parent 03319ea commit b15c8df

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
@@ -638,7 +638,7 @@ static int smcd_tx_sndbuf_nonempty(struct smc_connection *conn)
638638
return rc;
639639
}
640640

641-
static int __smc_tx_sndbuf_nonempty(struct smc_connection *conn)
641+
int smc_tx_sndbuf_nonempty(struct smc_connection *conn)
642642
{
643643
struct smc_sock *smc = container_of(conn, struct smc_sock, conn);
644644
int rc = 0;
@@ -672,34 +672,6 @@ static int __smc_tx_sndbuf_nonempty(struct smc_connection *conn)
672672
return rc;
673673
}
674674

675-
int smc_tx_sndbuf_nonempty(struct smc_connection *conn)
676-
{
677-
int rc;
678-
679-
/* This make sure only one can send simultaneously to prevent wasting
680-
* of CPU and CDC slot.
681-
* Record whether someone has tried to push while we are pushing.
682-
*/
683-
if (atomic_inc_return(&conn->tx_pushing) > 1)
684-
return 0;
685-
686-
again:
687-
atomic_set(&conn->tx_pushing, 1);
688-
smp_wmb(); /* Make sure tx_pushing is 1 before real send */
689-
rc = __smc_tx_sndbuf_nonempty(conn);
690-
691-
/* We need to check whether someone else have added some data into
692-
* the send queue and tried to push but failed after the atomic_set()
693-
* when we are pushing.
694-
* If so, we need to push again to prevent those data hang in the send
695-
* queue.
696-
*/
697-
if (unlikely(!atomic_dec_and_test(&conn->tx_pushing)))
698-
goto again;
699-
700-
return rc;
701-
}
702-
703675
/* Wakeup sndbuf consumers from process context
704676
* since there is more data to transmit. The caller
705677
* must hold sock lock.

0 commit comments

Comments
 (0)