> -----Original Message----- > From: Leon Romanovsky <leon@xxxxxxxxxx> > Sent: Sunday, December 16, 2018 12:58 AM > To: Parav Pandit <parav@xxxxxxxxxxxx> > Cc: linux-rdma@xxxxxxxxxxxxxxx; jgg@xxxxxxxx; dledford@xxxxxxxxxx; Moni > Shoua <monis@xxxxxxxxxxxx> > Subject: Re: [PATCHv1] IB/rxe: Make counters thread safe > > On Fri, Dec 14, 2018 at 12:32:42AM -0600, Parav Pandit wrote: > > 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@xxxxxxxxxxxx> > > --- > > drivers/infiniband/sw/rxe/rxe_hw_counters.c | 2 +- > > drivers/infiniband/sw/rxe/rxe_verbs.h | 6 +++--- > > 2 files changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/infiniband/sw/rxe/rxe_hw_counters.c > b/drivers/infiniband/sw/rxe/rxe_hw_counters.c > > index 4a24895..636edb5 100644 > > --- a/drivers/infiniband/sw/rxe/rxe_hw_counters.c > > +++ b/drivers/infiniband/sw/rxe/rxe_hw_counters.c > > @@ -62,7 +62,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]); > > atomic64_read receives atomic64_t as an input and not u64 as declared by > stats_counters. I didn't follow you. In this patch, in rxe_verbs.h stats_counters of the device is declared as atomic64_t.