Message ID | 20220707142144.459751-3-haris.iqbal@ionos.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Misc patches for RTRS | expand |
On 7/7/22 10:21 PM, Md Haris Iqbal wrote: > From: Santosh Kumar Pradhan <santosh.pradhan@ionos.com> > > Use this_cpu_x() for increasing/adding a percpu counter through a > percpu pointer without the need to disable/enable preemption. > > Suggested-by: Christoph Lameter <cl@linux.com> > Signed-off-by: Santosh Kumar Pradhan <santosh.pradhan@ionos.com> > Signed-off-by: Jack Wang <jinpu.wang@ionos.com> > Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com> > --- > drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c | 14 +++----------- > 1 file changed, 3 insertions(+), 11 deletions(-) > > diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c b/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c > index 385a19846c24..1e6ffafa2db3 100644 > --- a/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c > +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c > @@ -32,11 +32,7 @@ void rtrs_clt_update_wc_stats(struct rtrs_clt_con *con) > > void rtrs_clt_inc_failover_cnt(struct rtrs_clt_stats *stats) > { > - struct rtrs_clt_stats_pcpu *s; > - > - s = get_cpu_ptr(stats->pcpu_stats); > - s->rdma.failover_cnt++; > - put_cpu_ptr(stats->pcpu_stats); > + this_cpu_inc(stats->pcpu_stats->rdma.failover_cnt); > } > > int rtrs_clt_stats_migration_from_cnt_to_str(struct rtrs_clt_stats *stats, char *buf) > @@ -169,12 +165,8 @@ int rtrs_clt_reset_all_stats(struct rtrs_clt_stats *s, bool enable) > static inline void rtrs_clt_update_rdma_stats(struct rtrs_clt_stats *stats, > size_t size, int d) > { > - struct rtrs_clt_stats_pcpu *s; > - > - s = get_cpu_ptr(stats->pcpu_stats); > - s->rdma.dir[d].cnt++; > - s->rdma.dir[d].size_total += size; > - put_cpu_ptr(stats->pcpu_stats); > + this_cpu_inc(stats->pcpu_stats->rdma.dir[d].cnt); > + this_cpu_add(stats->pcpu_stats->rdma.dir[d].size_total, size); > } > > void rtrs_clt_update_all_stats(struct rtrs_clt_io_req *req, int dir) Acked-by: Guoqing Jiang <guoqing.jiang@linux.dev> Thanks, Guoqing
> Use this_cpu_x() for increasing/adding a percpu counter through a > percpu pointer without the need to disable/enable preemption. Reviewed-by: Christoph Lameter <cl@linux.com>
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c b/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c index 385a19846c24..1e6ffafa2db3 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c @@ -32,11 +32,7 @@ void rtrs_clt_update_wc_stats(struct rtrs_clt_con *con) void rtrs_clt_inc_failover_cnt(struct rtrs_clt_stats *stats) { - struct rtrs_clt_stats_pcpu *s; - - s = get_cpu_ptr(stats->pcpu_stats); - s->rdma.failover_cnt++; - put_cpu_ptr(stats->pcpu_stats); + this_cpu_inc(stats->pcpu_stats->rdma.failover_cnt); } int rtrs_clt_stats_migration_from_cnt_to_str(struct rtrs_clt_stats *stats, char *buf) @@ -169,12 +165,8 @@ int rtrs_clt_reset_all_stats(struct rtrs_clt_stats *s, bool enable) static inline void rtrs_clt_update_rdma_stats(struct rtrs_clt_stats *stats, size_t size, int d) { - struct rtrs_clt_stats_pcpu *s; - - s = get_cpu_ptr(stats->pcpu_stats); - s->rdma.dir[d].cnt++; - s->rdma.dir[d].size_total += size; - put_cpu_ptr(stats->pcpu_stats); + this_cpu_inc(stats->pcpu_stats->rdma.dir[d].cnt); + this_cpu_add(stats->pcpu_stats->rdma.dir[d].size_total, size); } void rtrs_clt_update_all_stats(struct rtrs_clt_io_req *req, int dir)