]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
IB/rxe: Make counters thread safe
authorParav Pandit <parav@mellanox.com>
Fri, 14 Dec 2018 06:32:42 +0000 (00:32 -0600)
committerMarcelo Henrique Cerri <marcelo.cerri@canonical.com>
Fri, 17 Jan 2020 17:21:35 +0000 (14:21 -0300)
BugLink: https://bugs.launchpad.net/bugs/1855787
[ Upstream commit d5108e69fe013ff47ab815b849caba9cc33ca1e5 ]

Current rxe device counters are not thread safe.
When multiple QPs are used, they can be racy.
Make them thread safe by making it atomic64.

Fixes: 0b1e5b99a48b ("IB/rxe: Add port protocol stats")
Signed-off-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/infiniband/sw/rxe/rxe_hw_counters.c
drivers/infiniband/sw/rxe/rxe_verbs.h

index 6aeb7a165e46919c1c3651d72776fd05f03173b1..ea4542a9d69e68523558455c138412f9b6341684 100644 (file)
@@ -59,7 +59,7 @@ int rxe_ib_get_hw_stats(struct ib_device *ibdev,
                return -EINVAL;
 
        for (cnt = 0; cnt  < ARRAY_SIZE(rxe_counter_name); cnt++)
-               stats->value[cnt] = dev->stats_counters[cnt];
+               stats->value[cnt] = atomic64_read(&dev->stats_counters[cnt]);
 
        return ARRAY_SIZE(rxe_counter_name);
 }
index ec99c55bd0a340ca16a235053921f48ae9596e43..4324fb6e433565dde8954eefe24e579443c222c7 100644 (file)
@@ -411,16 +411,16 @@ struct rxe_dev {
        spinlock_t              mmap_offset_lock; /* guard mmap_offset */
        int                     mmap_offset;
 
-       u64                     stats_counters[RXE_NUM_OF_COUNTERS];
+       atomic64_t              stats_counters[RXE_NUM_OF_COUNTERS];
 
        struct rxe_port         port;
        struct list_head        list;
        struct crypto_shash     *tfm;
 };
 
-static inline void rxe_counter_inc(struct rxe_dev *rxe, enum rxe_counters cnt)
+static inline void rxe_counter_inc(struct rxe_dev *rxe, enum rxe_counters index)
 {
-       rxe->stats_counters[cnt]++;
+       atomic64_inc(&rxe->stats_counters[index]);
 }
 
 static inline struct rxe_dev *to_rdev(struct ib_device *dev)