Skip to content

Commit 126f760

Browse files
Hakon-Buggedavem330
authored andcommitted
rds: Fix incorrect statistics counting
In rds_send_xmit() there is logic to batch the sends. However, if another thread has acquired the lock and has incremented the send_gen, it is considered a race and we yield. The code incrementing the s_send_lock_queue_raced statistics counter did not count this event correctly. This commit counts the race condition correctly. Changes from v1: - Removed check for *someone_on_xmit()* - Fixed incorrect indentation Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com> Reviewed-by: Knut Omang <knut.omang@oracle.com> Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent eef5a7c commit 126f760

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

net/rds/send.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,14 +428,18 @@ int rds_send_xmit(struct rds_conn_path *cp)
428428
* some work and we will skip our goto
429429
*/
430430
if (ret == 0) {
431+
bool raced;
432+
431433
smp_mb();
434+
raced = send_gen != READ_ONCE(cp->cp_send_gen);
435+
432436
if ((test_bit(0, &conn->c_map_queued) ||
433-
!list_empty(&cp->cp_send_queue)) &&
434-
send_gen == READ_ONCE(cp->cp_send_gen)) {
435-
rds_stats_inc(s_send_lock_queue_raced);
437+
!list_empty(&cp->cp_send_queue)) && !raced) {
436438
if (batch_count < send_batch_count)
437439
goto restart;
438440
queue_delayed_work(rds_wq, &cp->cp_send_w, 1);
441+
} else if (raced) {
442+
rds_stats_inc(s_send_lock_queue_raced);
439443
}
440444
}
441445
out:

0 commit comments

Comments
 (0)