Skip to contentSkip to conversation

rds: introduce acquire/release ordering in acquire/release_in_xmit()

PATCH Applied Yewon Choi 3 participants 3 messages Mar 15, 2024 – Mar 19, 2024

Subsystems (4)
lore
Share & tools
lore

Yewon Choi

author
#0 lore raw

PATCH v2 1/1 rds: introduce acquire/release ordering in acquire/release_in_xmit()

acquire/release_in_xmit() work as bit lock in rds_send_xmit(), so they are expected to ensure acquire/release memory ordering semantics. However, test_and_set_bit/clear_bit() don't imply such semantics, on top of this, following smp_mb__after_atomic() does not guarantee release ordering (memory barrier actually should be placed before clear_bit()).

Instead, we use clear_bit_unlock/test_and_set_bit_lock() here.

Fixes 0f4b1c7e89e6 ("rds: fix rds_send_xmit() serialization")
Fixes 1f9ecd7eacfd ("RDS: Pass rds_conn_path to rds_send_xmit()")

---
Changes in v1 -> v2:
- Added missing Fixes tags

 net/rds/send.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
net/rds/send.c +2 -3
index 5e57a1581dc6..8f38009721b7 100644
@@ -103,13 +103,12 @@ EXPORT_SYMBOL_GPL(rds_send_path_reset);
 
 static int acquire_in_xmit(struct rds_conn_path *cp)
 {
-	return test_and_set_bit(RDS_IN_XMIT, &cp->cp_flags) == 0;
+	return test_and_set_bit_lock(RDS_IN_XMIT, &cp->cp_flags) == 0;
 }
 
 static void release_in_xmit(struct rds_conn_path *cp)
 {
-	clear_bit(RDS_IN_XMIT, &cp->cp_flags);
-	smp_mb__after_atomic();
+	clear_bit_unlock(RDS_IN_XMIT, &cp->cp_flags);
 	/*
 	 * We don't use wait_on_bit()/wake_up_bit() because our waking is in a
 	 * hot path and finding waiters is very rare.  We don't want to walk
Signature · 1 line
2.43.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 41 lines · Yewon Choi

acquire/release_in_xmit() work as bit lock in rds_send_xmit(), so they are expected to ensure acquire/release memory ordering semantics. However, test_and_set_bit/clear_bit() don't imply such semantics, on top of this, following smp_mb__after_atomic() does not guarantee release ordering (memory barrier actually should be placed before clear_bit()).

Instead, we use clear_bit_unlock/test_and_set_bit_lock() here.

Fixes 0f4b1c7e89e6 ("rds: fix rds_send_xmit() serialization")
Fixes 1f9ecd7eacfd ("RDS: Pass rds_conn_path to rds_send_xmit()")

---
Changes in v1 -> v2:
- Added missing Fixes tags

 net/rds/send.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
net/rds/send.c +2 -3
index 5e57a1581dc6..8f38009721b7 100644
@@ -103,13 +103,12 @@ EXPORT_SYMBOL_GPL(rds_send_path_reset);
 
 static int acquire_in_xmit(struct rds_conn_path *cp)
 {
-	return test_and_set_bit(RDS_IN_XMIT, &cp->cp_flags) == 0;
+	return test_and_set_bit_lock(RDS_IN_XMIT, &cp->cp_flags) == 0;
 }
 
 static void release_in_xmit(struct rds_conn_path *cp)
 {
-	clear_bit(RDS_IN_XMIT, &cp->cp_flags);
-	smp_mb__after_atomic();
+	clear_bit_unlock(RDS_IN_XMIT, &cp->cp_flags);
 	/*
 	 * We don't use wait_on_bit()/wake_up_bit() because our waking is in a
 	 * hot path and finding waiters is very rare.  We don't want to walk
Signature · 1 line
2.43.0

LGTM

Thanks,

#2 lore raw
In reply to Yewon Choi
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

Quoted 9 lines · On Fri, 15 Mar 2024 18:28:38 +0900 you wrote:

acquire/release_in_xmit() work as bit lock in rds_send_xmit(), so they are expected to ensure acquire/release memory ordering semantics. However, test_and_set_bit/clear_bit() don't imply such semantics, on top of this, following smp_mb__after_atomic() does not guarantee release ordering (memory barrier actually should be placed before clear_bit()).

Instead, we use clear_bit_unlock/test_and_set_bit_lock() here.

[...]

Here is the summary with links:
- [net,v2] rds: introduce acquire/release ordering in acquire/release_in_xmit()

    https://git.kernel.org/netdev/net/c/1422f28826d2

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html