]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
rds: Fix incorrect statistics counting
authorHåkon Bugge <Haakon.Bugge@oracle.com>
Wed, 6 Sep 2017 16:35:51 +0000 (18:35 +0200)
committerChuck Anderson <chuck.anderson@oracle.com>
Mon, 25 Sep 2017 22:35:27 +0000 (15:35 -0700)
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.

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>
(cherry-picked from upstream 126f760ca94dae77425695f9f9238b731de86e32)

Orabug: 26847583

Conflicts:
net/rds/send.c

Reviewed-by: Avinash Repaka <avinash.repaka@oracle.com>
net/rds/send.c

index bd71f388b231af66e16959c9343390b645c51426..c203654c7bddbe8a79bb6d99b556414502c7d96f 100644 (file)
@@ -495,14 +495,18 @@ over_batch:
         * some work and we will skip our goto
         */
        if (ret == 0) {
+               bool raced;
+
                smp_mb();
+               raced = send_gen != READ_ONCE(cp->cp_send_gen);
+
                if ((test_bit(0, &conn->c_map_queued) ||
-                    !list_empty(&cp->cp_send_queue)) &&
-                       send_gen == READ_ONCE(cp->cp_send_gen)) {
-                       rds_stats_inc(s_send_lock_queue_raced);
+                   !list_empty(&cp->cp_send_queue)) && !raced) {
                        if (batch_count < send_batch_count)
                                goto restart;
                        queue_delayed_work(cp->cp_wq, &cp->cp_send_w, 1);
+               } else if (raced) {
+                       rds_stats_inc(s_send_lock_queue_raced);
                }
        }
 out: