event/octeontx2: use C11 atomics for statistics
authorPavan Nikhilesh <pbhagavatula@marvell.com>
Fri, 27 Mar 2020 08:55:58 +0000 (14:25 +0530)
committerJerin Jacob <jerinj@marvell.com>
Sat, 4 Apr 2020 16:38:43 +0000 (18:38 +0200)
Use c11 atomics with RELAXED ordering instead of rte_atomic ops which
enforce unnessary barriers on arm64.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Reviewed-by: Phil Yang <phil.yang@arm.com>
drivers/event/octeontx2/otx2_tim_evdev.c
drivers/event/octeontx2/otx2_tim_evdev.h
drivers/event/octeontx2/otx2_tim_worker.c

index cd0dcde..4c24cc8 100644 (file)
@@ -526,7 +526,8 @@ otx2_tim_stats_get(const struct rte_event_timer_adapter *adapter,
        uint64_t bkt_cyc = rte_rdtsc() - tim_ring->ring_start_cyc;
 
 
-       stats->evtim_exp_count = rte_atomic64_read(&tim_ring->arm_cnt);
+       stats->evtim_exp_count = __atomic_load_n(&tim_ring->arm_cnt,
+                                                __ATOMIC_RELAXED);
        stats->ev_enq_count = stats->evtim_exp_count;
        stats->adapter_tick_count = rte_reciprocal_divide_u64(bkt_cyc,
                                &tim_ring->fast_div);
@@ -538,7 +539,7 @@ otx2_tim_stats_reset(const struct rte_event_timer_adapter *adapter)
 {
        struct otx2_tim_ring *tim_ring = adapter->data->adapter_priv;
 
-       rte_atomic64_clear(&tim_ring->arm_cnt);
+       __atomic_store_n(&tim_ring->arm_cnt, 0, __ATOMIC_RELAXED);
        return 0;
 }
 
index 56895dc..44e3c7b 100644 (file)
@@ -149,7 +149,7 @@ struct otx2_tim_ring {
        struct otx2_tim_bkt *bkt;
        struct rte_mempool *chunk_pool;
        struct rte_reciprocal_u64 fast_div;
-       rte_atomic64_t arm_cnt;
+       uint64_t arm_cnt;
        uint8_t prod_type_sp;
        uint8_t enable_stats;
        uint8_t disable_npa;
index 104674c..4b5cfdc 100644 (file)
@@ -88,7 +88,7 @@ tim_timer_arm_burst(const struct rte_event_timer_adapter *adptr,
        }
 
        if (flags & OTX2_TIM_ENA_STATS)
-               rte_atomic64_add(&tim_ring->arm_cnt, index);
+               __atomic_fetch_add(&tim_ring->arm_cnt, index, __ATOMIC_RELAXED);
 
        return index;
 }
@@ -130,7 +130,8 @@ tim_timer_arm_tmo_brst(const struct rte_event_timer_adapter *adptr,
                        break;
        }
        if (flags & OTX2_TIM_ENA_STATS)
-               rte_atomic64_add(&tim_ring->arm_cnt, set_timers);
+               __atomic_fetch_add(&tim_ring->arm_cnt, set_timers,
+                                  __ATOMIC_RELAXED);
 
        return set_timers;
 }