net/rds: use wq_has_sleeper() in rds_cong_map_updated()
Subsystems (4)
Allison Henderson
maintainerPATCH 1/1 net/rds: use wq_has_sleeper() in rds_cong_map_updated()
rds_cong_map_updated() runs after a peer's congestion map has been rewritten (by rds_tcp_cong_recv() and rds_ib_cong_recv(), or the clear-all in the loopback and IB send-completion paths). It bumps rds_cong_generation and then checks waitqueue_active() on map->m_waitq and on rds_poll_waitq to decide whether anyone needs waking. atomic_inc() carries no ordering and waitqueue_active() is a plain load, so nothing orders the map and generation stores before the wait queue reads. The waiters do the mirror image: rds_cong_wait() adds itself to m_waitq and then tests the port bit, and rds_poll() registers on rds_poll_waitq and then reads the generation. That is the store-buffering pattern described above waitqueue_active() in include/linux/wait.h - the updater can observe an empty wait queue while the waiter still observes the port as congested, and no wake-up is issued.
rds_cong_wait() is an interruptible sleep with no timeout, so a sender blocked on a congested port stays blocked until the next congestion update from that peer arrives or a signal is delivered. A poll() waiter misses the map-updated notification the same way.
Use wq_has_sleeper(), which is waitqueue_active() preceded by the required full barrier, as rds_tcp_state_change() already does for the same pattern.
---
Raised during review of "net/rds: own the fastpath locks across connection teardown", whose first patch fixes the same pattern in release_in_xmit():
https://lore.kernel.org/netdev/[email protected]/
This patch is independent of that set and applies on its own.
net/rds/cong.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/rds/cong.c +2 -2
@@ -256,9 +256,9 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask) map, &map->m_addr);rds_stats_inc (s_cong_update_received);atomic_inc (&rds_cong_generation); -if (waitqueue_active (&map->m_waitq)) +if (wq_has_sleeper (&map->m_waitq))wake_up (&map->m_waitq); -if (waitqueue_active (&rds_poll_waitq)) +if (wq_has_sleeper (&rds_poll_waitq))wake_up_all (&rds_poll_waitq);if (portmask && !list_empty (&rds_cong_monitor)) {
base-commit: 4e15e89faac9f308baeb01f46c13a051814d2449
Signature · 1 line
2.25.1
Quoted 27 lines · Allison Henderson
rds_cong_map_updated()runs after a peer's congestion map has been rewritten (byrds_tcp_cong_recv()andrds_ib_cong_recv(), or the clear-all in the loopback and IB send-completion paths). It bumpsrds_cong_generationand then checkswaitqueue_active()onmap->m_waitqand onrds_poll_waitqto decide whether anyone needs waking.atomic_inc()carries no ordering andwaitqueue_active()is a plain load, so nothing orders the map and generation stores before the wait queue reads. The waiters do the mirror image:rds_cong_wait()adds itself tom_waitqand then tests the port bit, andrds_poll()registers onrds_poll_waitqand then reads the generation. That is the store-buffering pattern described abovewaitqueue_active()ininclude/linux/wait.h- the updater can observe an empty wait queue while the waiter still observes the port as congested, and no wake-up is issued.
rds_cong_wait()is an interruptible sleep with no timeout, so a sender blocked on a congested port stays blocked until the next congestion update from that peer arrives or a signal is delivered. Apoll()waiter misses the map-updated notification the same way.Use
wq_has_sleeper(), which iswaitqueue_active()preceded by the required full barrier, asrds_tcp_state_change()already does for the same pattern.Fixes 922cb17a5c81 ("RDS: Congestion-handling code")Assisted-by Claude-Code:claude-fable-5Signed-off-by Allison Henderson <[email protected]>
Quoted 6 lines
---
Raised during review of "net/rds: own the fastpath locks across connection teardown", whose first patch fixes the same pattern inrelease_in_xmit():
https://lore.kernel.org/netdev/[email protected]/
This patch is independent of that set and applies on its own.
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 15 lines · On Fri, 21 Aug 2026 22:26:47 -0700 you wrote:
rds_cong_map_updated()runs after a peer's congestion map has been rewritten (byrds_tcp_cong_recv()andrds_ib_cong_recv(), or the clear-all in the loopback and IB send-completion paths). It bumpsrds_cong_generationand then checkswaitqueue_active()onmap->m_waitqand onrds_poll_waitqto decide whether anyone needs waking.atomic_inc()carries no ordering andwaitqueue_active()is a plain load, so nothing orders the map and generation stores before the wait queue reads. The waiters do the mirror image:rds_cong_wait()adds itself tom_waitqand then tests the port bit, andrds_poll()registers onrds_poll_waitqand then reads the generation. That is the store-buffering pattern described abovewaitqueue_active()ininclude/linux/wait.h- the updater can observe an empty wait queue while the waiter still observes the port as congested, and no wake-up is issued.
Quoted 1 line
[...]
Here is the summary with links:
- [net] net/rds: use wq_has_sleeper() in rds_cong_map_updated()
https://git.kernel.org/netdev/net/c/d4f484661961
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html