Skip to content

Commit d5108e6

Browse files
paravmellanoxjgunthorpe
authored andcommitted
IB/rxe: Make counters thread safe
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: 0b1e5b9 ("IB/rxe: Add port protocol stats") Signed-off-by: Parav Pandit <parav@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent 6e3722b commit d5108e6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

drivers/infiniband/sw/rxe/rxe_hw_counters.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ int rxe_ib_get_hw_stats(struct ib_device *ibdev,
6262
return -EINVAL;
6363

6464
for (cnt = 0; cnt < ARRAY_SIZE(rxe_counter_name); cnt++)
65-
stats->value[cnt] = dev->stats_counters[cnt];
65+
stats->value[cnt] = atomic64_read(&dev->stats_counters[cnt]);
6666

6767
return ARRAY_SIZE(rxe_counter_name);
6868
}

drivers/infiniband/sw/rxe/rxe_verbs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,16 +409,16 @@ struct rxe_dev {
409409
spinlock_t mmap_offset_lock; /* guard mmap_offset */
410410
int mmap_offset;
411411

412-
u64 stats_counters[RXE_NUM_OF_COUNTERS];
412+
atomic64_t stats_counters[RXE_NUM_OF_COUNTERS];
413413

414414
struct rxe_port port;
415415
struct list_head list;
416416
struct crypto_shash *tfm;
417417
};
418418

419-
static inline void rxe_counter_inc(struct rxe_dev *rxe, enum rxe_counters cnt)
419+
static inline void rxe_counter_inc(struct rxe_dev *rxe, enum rxe_counters index)
420420
{
421-
rxe->stats_counters[cnt]++;
421+
atomic64_inc(&rxe->stats_counters[index]);
422422
}
423423

424424
static inline struct rxe_dev *to_rdev(struct ib_device *dev)

0 commit comments

Comments
 (0)