* [PATCH net-next v4] net/smc: remove unneeded atomic operations in smc_tx_sndbuf_nonempty
@ 2023-11-23 1:45 Li RongQing
2023-11-24 12:16 ` Alexandra Winter
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Li RongQing @ 2023-11-23 1:45 UTC (permalink / raw)
To: linux-s390, netdev, wintera, dust.li
The commit dcd2cf5f2fc0 ("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 6b88af839d20 ("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>
---
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(-)
diff --git a/net/smc/smc.h b/net/smc/smc.h
index e377980..cd51261 100644
--- a/net/smc/smc.h
+++ b/net/smc/smc.h
@@ -196,7 +196,6 @@ struct smc_connection {
* - dec on polled tx cqe
*/
wait_queue_head_t cdc_pend_tx_wq; /* wakeup on no cdc_pend_tx_wr*/
- atomic_t tx_pushing; /* nr_threads trying tx push */
struct delayed_work tx_work; /* retry of smc_cdc_msg_send */
u32 tx_off; /* base offset in peer rmb */
diff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c
index 3b0ff3b..214ac3c 100644
--- a/net/smc/smc_tx.c
+++ b/net/smc/smc_tx.c
@@ -621,7 +621,7 @@ static int smcd_tx_sndbuf_nonempty(struct smc_connection *conn)
return rc;
}
-static int __smc_tx_sndbuf_nonempty(struct smc_connection *conn)
+int smc_tx_sndbuf_nonempty(struct smc_connection *conn)
{
struct smc_sock *smc = container_of(conn, struct smc_sock, conn);
int rc = 0;
@@ -655,34 +655,6 @@ static int __smc_tx_sndbuf_nonempty(struct smc_connection *conn)
return rc;
}
-int smc_tx_sndbuf_nonempty(struct smc_connection *conn)
-{
- int rc;
-
- /* This make sure only one can send simultaneously to prevent wasting
- * of CPU and CDC slot.
- * Record whether someone has tried to push while we are pushing.
- */
- if (atomic_inc_return(&conn->tx_pushing) > 1)
- return 0;
-
-again:
- atomic_set(&conn->tx_pushing, 1);
- smp_wmb(); /* Make sure tx_pushing is 1 before real send */
- rc = __smc_tx_sndbuf_nonempty(conn);
-
- /* We need to check whether someone else have added some data into
- * the send queue and tried to push but failed after the atomic_set()
- * when we are pushing.
- * If so, we need to push again to prevent those data hang in the send
- * queue.
- */
- if (unlikely(!atomic_dec_and_test(&conn->tx_pushing)))
- goto again;
-
- return rc;
-}
-
/* Wakeup sndbuf consumers from process context
* since there is more data to transmit. The caller
* must hold sock lock.
--
2.9.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v4] net/smc: remove unneeded atomic operations in smc_tx_sndbuf_nonempty
2023-11-23 1:45 [PATCH net-next v4] net/smc: remove unneeded atomic operations in smc_tx_sndbuf_nonempty Li RongQing
@ 2023-11-24 12:16 ` Alexandra Winter
2023-11-24 12:55 ` Wenjia Zhang
2023-11-28 1:57 ` Jakub Kicinski
2 siblings, 0 replies; 4+ messages in thread
From: Alexandra Winter @ 2023-11-24 12:16 UTC (permalink / raw)
To: Li RongQing, linux-s390, netdev, dust.li
On 23.11.23 02:45, Li RongQing wrote:
> The commit dcd2cf5f2fc0 ("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 6b88af839d20 ("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>
> ---
Looks good to me.
Reviewed-by: Alexandra Winter <wintera@linux.ibm.com>
However I think this time you did not use scripts/get_maintainer.pl [1]
to determine the correct recipient list for this email.
[1] https://www.kernel.org/doc/html/v6.3/process/submitting-patches.html#submittingpatches
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v4] net/smc: remove unneeded atomic operations in smc_tx_sndbuf_nonempty
2023-11-23 1:45 [PATCH net-next v4] net/smc: remove unneeded atomic operations in smc_tx_sndbuf_nonempty Li RongQing
2023-11-24 12:16 ` Alexandra Winter
@ 2023-11-24 12:55 ` Wenjia Zhang
2023-11-28 1:57 ` Jakub Kicinski
2 siblings, 0 replies; 4+ messages in thread
From: Wenjia Zhang @ 2023-11-24 12:55 UTC (permalink / raw)
To: Li RongQing, linux-s390, netdev, wintera, dust.li
On 23.11.23 02:45, Li RongQing wrote:
> The commit dcd2cf5f2fc0 ("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 6b88af839d20 ("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>
> ---
To the patch, LGTM! Again, please copy the related subsystem maintainers
explicitly!
Reviewed-and-tested-by: Wenjia Zhang <wenjia@linux.ibm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v4] net/smc: remove unneeded atomic operations in smc_tx_sndbuf_nonempty
2023-11-23 1:45 [PATCH net-next v4] net/smc: remove unneeded atomic operations in smc_tx_sndbuf_nonempty Li RongQing
2023-11-24 12:16 ` Alexandra Winter
2023-11-24 12:55 ` Wenjia Zhang
@ 2023-11-28 1:57 ` Jakub Kicinski
2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2023-11-28 1:57 UTC (permalink / raw)
To: Li RongQing; +Cc: linux-s390, netdev, wintera, dust.li
On Thu, 23 Nov 2023 09:45:37 +0800 Li RongQing wrote:
> The commit dcd2cf5f2fc0 ("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()
Looks like this was applied by DaveM - commit e7bed88e0530 ("net/smc:
remove unneeded atomic operations in smc_tx_sndbuf_nonempty") in net-next.
Thank you!
--
pw-bot: accept
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-11-28 1:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-23 1:45 [PATCH net-next v4] net/smc: remove unneeded atomic operations in smc_tx_sndbuf_nonempty Li RongQing
2023-11-24 12:16 ` Alexandra Winter
2023-11-24 12:55 ` Wenjia Zhang
2023-11-28 1:57 ` Jakub Kicinski
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.