use compiler atomic builtins for app
cover use compiler atomic builtins for app
Since atomic operations have been adopted in DPDK now[1], change rte_atomicNN_xxx APIs to compiler's atomic built-ins in app module[2].
[1] https://www.dpdk.org/blog/2021/03/26/dpdk-adopts-the-c11-memory-model/
[2] https://doc.dpdk.org/guides/rel_notes/deprecation.html
Joyce Kong (12):
test/pmd_perf: use compiler atomic builtins for polling sync test/ring_perf: use compiler atomic builtins for lcores sync test/timer: use compiler atomic builtins for sync test/stack_perf: use compiler atomics for lcore sync test/bpf: use compiler atomics for calculation test/func_reentrancy: use compiler atomic for data sync app/eventdev: use compiler atomic builtins for packets sync app/crypto: use compiler atomic builtins for display sync app/compress: use compiler atomic builtins for display sync app/testpmd: use compiler atomic builtins for port sync app/bbdev: use compiler atomics for thread sync
app: remove unnecessary include of atomic
app/proc-info/main.c | 1 - app/test-bbdev/test_bbdev_perf.c | 135 ++++++++---------- .../comp_perf_test_common.h | 2 +- .../comp_perf_test_cyclecount.c | 10 +- .../comp_perf_test_throughput.c | 11 +- .../comp_perf_test_verify.c | 6 +- app/test-crypto-perf/cperf_test_latency.c | 6 +- .../cperf_test_pmd_cyclecount.c | 9 +- app/test-crypto-perf/cperf_test_throughput.c | 9 +- app/test-crypto-perf/cperf_test_verify.c | 9 +- app/test-eventdev/evt_main.c | 1 - app/test-eventdev/test_order_atq.c | 4 +- app/test-eventdev/test_order_common.c | 4 +- app/test-eventdev/test_order_common.h | 8 +- app/test-eventdev/test_order_queue.c | 4 +- app/test-pipeline/config.c | 1 - app/test-pipeline/init.c | 1 - app/test-pipeline/main.c | 1 - app/test-pipeline/runtime.c | 1 - app/test-pmd/cmdline.c | 1 - app/test-pmd/config.c | 1 - app/test-pmd/csumonly.c | 1 - app/test-pmd/flowgen.c | 1 - app/test-pmd/icmpecho.c | 1 - app/test-pmd/iofwd.c | 1 - app/test-pmd/macfwd.c | 1 - app/test-pmd/macswap.c | 1 - app/test-pmd/parameters.c | 1 - app/test-pmd/rxonly.c | 1 - app/test-pmd/testpmd.c | 75 ++++++---- app/test-pmd/txonly.c | 1 - app/test/test_barrier.c | 1 - app/test/test_bpf.c | 28 ++-- app/test/test_func_reentrancy.c | 27 ++-- app/test/test_mbuf.c | 1 - app/test/test_mp_secondary.c | 1 - app/test/test_pmd_perf.c | 12 +- app/test/test_ring.c | 1 - app/test/test_ring_perf.c | 9 +- app/test/test_stack_perf.c | 14 +- app/test/test_timer.c | 28 ++-- app/test/test_timer_secondary.c | 1 - 42 files changed, 213 insertions(+), 219 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/12 test/pmd_perf: use compiler atomic builtins for polling sync
Convert rte_atomic usages to compiler atomic built-ins for polling sync in pmd_perf test cases.
--- app/test/test_pmd_perf.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
app/test/test_pmd_perf.c +5 -7
@@ -10,7 +10,6 @@#include <rte_cycles.h> #include <rte_ethdev.h> #include <rte_byteorder.h> -#include <rte_atomic.h> #include <rte_malloc.h> #include "packet_burst_generator.h" #include "test.h"
@@ -526,7 +525,7 @@ main_loop(__rte_unused void *args)return 0 ; } -static rte_atomic64_t start; +static uint64_t start;static inline int poll_burst (void *args)
@@ -564,8 +563,7 @@ poll_burst(void *args) num[portid] = pkt_per_port; } -while (!rte_atomic64_read (&start)) - ; +rte_wait_until_equal_64 (&start,1 , __ATOMIC_RELAXED); cur_tsc =rte_rdtsc ();while (total) {
@@ -617,7 +615,7 @@ exec_burst(uint32_t flags, int lcore) pkt_per_port =MAX_TRAFFIC_BURST ; num = pkt_per_port * conf->nb_ports; -rte_atomic64_init (&start); +__atomic_store_n (&start,0 , __ATOMIC_RELAXED);/* start polling thread, but not actually poll yet */ rte_eal_remote_launch(poll_burst,
@@ -625,7 +623,7 @@ exec_burst(uint32_t flags, int lcore)/* Only when polling first */ if (flags ==SC_BURST_POLL_FIRST ) -rte_atomic64_set (&start,1 ); +__atomic_store_n (&start,1 , __ATOMIC_RELAXED);/* start xmit */ i =0 ;
@@ -642,7 +640,7 @@ exec_burst(uint32_t flags, int lcore)/* only when polling second */ if (flags ==SC_BURST_XMIT_FIRST ) -rte_atomic64_set (&start,1 ); +__atomic_store_n (&start,1 , __ATOMIC_RELAXED);/* wait for polling finished */ diff_tsc =rte_eal_wait_lcore (lcore);
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v1 01/12] test/pmd_perf: use compiler atomic builtins for polling sync
<snip>
Quoted 32 lines
Convert
rte_atomicusages to compiler atomic built-ins for polling sync inpmd_perftest cases.Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- app/test/test_pmd_perf.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)app/test/test_pmd_perf.c index renamed from app/test/test_pmd_perf.c +0
-0
3a248d512c..41ef001b90100644app/test/test_pmd_perf.c +1
-2@@ -10,7 +10,6 @@#include <rte_cycles.h> #include <rte_ethdev.h> #include <rte_byteorder.h> -#include <rte_atomic.h> #include <rte_malloc.h> #include "packet_burst_generator.h" #include "test.h" @@ -526,7 +525,7 @@ main_loop(__rte_unused void *args)return 0 ; } -static rte_atomic64_t start; +static uint64_t start;static inline int poll_burst (void *args)
app/test/test_pmd_perf.c poll_burst(void *args) · line 566
Quoted 6 lines
app/test/test_pmd_perf.c +1
-2@@ -564,8 +563,7 @@ poll_burst(void *args) num[portid] = pkt_per_port; } -while (!rte_atomic64_read (&start)) - ; +rte_wait_until_equal_64 (&start,1 , __ATOMIC_RELAXED);
This needs to be ACQUIRE. Please see comments below for function 'exec_burst'.
Quoted 13 lines
app/test/test_pmd_perf.c +1
-1cur_tsc =rte_rdtsc ();while (total) {@@ -617,7 +615,7 @@ exec_burst(uint32_t flags, int lcore) pkt_per_port =MAX_TRAFFIC_BURST ; num = pkt_per_port * conf->nb_ports; -rte_atomic64_init (&start); +__atomic_store_n (&start,0 , __ATOMIC_RELAXED);/* start polling thread, but not actually poll yet */ rte_eal_remote_launch(poll_burst,
app/test/test_pmd_perf.c exec_burst(uint32_t flags, int lcore) · line 626
Quoted 5 lines
app/test/test_pmd_perf.c +1
-1@@ -625,7 +623,7 @@ exec_burst(uint32_t flags, int lcore)/* Only when polling first */ if (flags ==SC_BURST_POLL_FIRST ) -rte_atomic64_set (&start,1 ); +__atomic_store_n (&start,1 , __ATOMIC_RELAXED);
This line can be combined with initialization of 'start'. i.e.
if (flags == SC_BURST_POLL_FIRST) {
__atomic_store_n(&start, 1, __ATOMIC_RELAXED);
} else {
__atomic_store_n(&start, 0, __ATOMIC_RELAXED);
}It is ok to use RELAXED here as it is part of initialization and 'rte_eal_remote_launch' will ensure that the store to 'start' is visible to the worker thread.
app/test/test_pmd_perf.c exec_burst(uint32_t flags, int lcore) · line 643
Quoted 9 lines
app/test/test_pmd_perf.c +1
-1/* start xmit */ i =0 ;@@ -642,7 +640,7 @@ exec_burst(uint32_t flags, int lcore)/* only when polling second */ if (flags ==SC_BURST_XMIT_FIRST ) -rte_atomic64_set (&start,1 ); +__atomic_store_n (&start,1 , __ATOMIC_RELAXED);
This store should happen after transmitting the packets. It is better to use RELEASE here.
Quoted 5 lines
app/test/test_pmd_perf.c +0
-1/* wait for polling finished */ diff_tsc =rte_eal_wait_lcore (lcore); --2.17.1
Re: [dpdk-dev] [PATCH v1 01/12] test/pmd_perf: use compiler atomic builtins for polling sync
Quoted 73 lines
<snip>
Quoted 32 lines
Convert
rte_atomicusages to compiler atomic built-ins for polling sync inpmd_perftest cases.Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- app/test/test_pmd_perf.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)app/test/test_pmd_perf.c index renamed from app/test/test_pmd_perf.c +0
-0
3a248d512c..41ef001b90100644app/test/test_pmd_perf.c +1
-2@@ -10,7 +10,6 @@#include <rte_cycles.h> #include <rte_ethdev.h> #include <rte_byteorder.h> -#include <rte_atomic.h> #include <rte_malloc.h> #include "packet_burst_generator.h" #include "test.h" @@ -526,7 +525,7 @@ main_loop(__rte_unused void *args)return 0 ; } -static rte_atomic64_t start; +static uint64_t start;static inline int poll_burst (void *args)app/test/test_pmd_perf.c poll_burst(void *args) · line 566
Quoted 6 lines
app/test/test_pmd_perf.c +1
-2@@ -564,8 +563,7 @@ poll_burst(void *args) num[portid] = pkt_per_port; } -while (!rte_atomic64_read (&start)) - ; +rte_wait_until_equal_64 (&start,1 , __ATOMIC_RELAXED);This needs to be ACQUIRE. Please see comments below for function '
exec_burst'.Quoted 13 lines
app/test/test_pmd_perf.c +1
-1cur_tsc =rte_rdtsc ();while (total) {@@ -617,7 +615,7 @@ exec_burst(uint32_t flags, int lcore) pkt_per_port =MAX_TRAFFIC_BURST ; num = pkt_per_port * conf->nb_ports; -rte_atomic64_init (&start); +__atomic_store_n (&start,0 , __ATOMIC_RELAXED);/* start polling thread, but not actually poll yet */ rte_eal_remote_launch(poll_burst,app/test/test_pmd_perf.c exec_burst(uint32_t flags, int lcore) · line 626
Quoted 5 lines
app/test/test_pmd_perf.c +1
-1@@ -625,7 +623,7 @@ exec_burst(uint32_t flags, int lcore)/* Only when polling first */ if (flags ==SC_BURST_POLL_FIRST ) -rte_atomic64_set (&start,1 ); +__atomic_store_n (&start,1 , __ATOMIC_RELAXED);This line can be combined with initialization of 'start'. i.e.
if (flags == SC_BURST_POLL_FIRST) { __atomic_store_n(&start, 1, __ATOMIC_RELAXED); } else { __atomic_store_n(&start, 0, __ATOMIC_RELAXED); } It is ok to useRELAXED here as it is part of initialization and '
rte_eal_remote_launch' will ensure that the store to 'start' is visible to the worker thread.Quoted 5 lines
app/test/test_pmd_perf.c +0
-0/* start xmit */ i =0 ;@@ -642,7 +640,7 @@ exec_burst(uint32_t flags, int lcore)
Quoted 6 lines
app/test/test_pmd_perf.c exec_burst(uint32_t flags, int lcore) · line 643
Quoted 4 lines
app/test/test_pmd_perf.c +1
-1/* only when polling second */ if (flags ==SC_BURST_XMIT_FIRST ) -rte_atomic64_set (&start,1 ); +__atomic_store_n (&start,1 , __ATOMIC_RELAXED);This store should happen after transmitting the packets. It is better to use RELEASE here.
Thanks, Honnappa, will make the changes in next version. Joyce
Quoted 6 lines
Quoted 6 lines
app/test/test_pmd_perf.c +0
-1/* wait for polling finished */ diff_tsc =rte_eal_wait_lcore (lcore); --2.17.1
PATCH 2/12 test/ring_perf: use compiler atomic builtins for lcores sync
In reply to Joyce KongConvert rte_atomic usages to compiler atomic built-ins for lcores sync in ring_perf test cases.
--- app/test/test_ring_perf.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
app/test/test_ring_perf.c +4 -5
@@ -320,7 +320,7 @@ run_on_core_pair(struct lcore_pair *cores, struct rte_ring *r, const int esize)return 0 ; } -static rte_atomic32_t synchro; +static uint32_t synchro;static uint64_t queue_count[RTE_MAX_LCORE ];#define TIME_MS 100
@@ -342,8 +342,7 @@ load_loop_fn_helper(struct thread_params *p, const int esize)/* wait synchro for workers */ if (lcore !=rte_get_main_lcore ()) -while (rte_atomic32_read (&synchro) ==0 ) -rte_pause (); +rte_wait_until_equal_32 (&synchro,1 , __ATOMIC_RELAXED); begin =rte_get_timer_cycles ();while (time_diff < hz *TIME_MS /1000 ) {
@@ -398,12 +397,12 @@ run_on_all_cores(struct rte_ring *r, const int esize) param.r = r;/* clear synchro and start workers */ -rte_atomic32_set (&synchro,0 ); +__atomic_store_n (&synchro,0 , __ATOMIC_RELAXED);if (rte_eal_mp_remote_launch (lcore_f, ¶m,SKIP_MAIN ) <0 )return -1 ;/* start synchro and launch test on main */ -rte_atomic32_set (&synchro,1 ); +__atomic_store_n (&synchro,1 , __ATOMIC_RELAXED);lcore_f (¶m);rte_eal_mp_wait_lcore ();
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v1 02/12] test/ring_perf: use compiler atomic builtins for lcores sync
<snip>
Quoted 6 lines
Convert
rte_atomicusages to compiler atomic built-ins for lcores sync inring_perftest cases.Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>
Looks good.
Quoted 47 lines
--- app/test/test_ring_perf.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)app/test/test_ring_perf.c index renamed from app/test/test_ring_perf.c +0
-0
fd82e20412..2d8bb675a3100644app/test/test_ring_perf.c +1
-1@@ -320,7 +320,7 @@ run_on_core_pair(struct lcore_pair *cores, struct rte_ring *r, const int esize) return 0; } -static rte_atomic32_t synchro; +static uint32_t synchro;static uint64_t queue_count[RTE_MAX_LCORE ];#define
TIME_MS100app/test/test_ring_perf.c +1
-2@@ -342,8 +342,7 @@ load_loop_fn_helper(struct thread_params *p, const int esize)/* wait synchro for workers */ if (lcore !=rte_get_main_lcore ()) -while (rte_atomic32_read (&synchro) ==0 ) -rte_pause (); +rte_wait_until_equal_32 (&synchro,1 , __ATOMIC_RELAXED); begin =rte_get_timer_cycles ();while (
time_diff< hz *TIME_MS/ 1000) { @@ -398,12 +397,12 @@run_on_all_cores(struct rte_ring *r, const int esize)app/test/test_ring_perf.c +1
-1param.r = r;/* clear synchro and start workers */ -rte_atomic32_set (&synchro,0 ); +__atomic_store_n (&synchro,0 , __ATOMIC_RELAXED); if (rte_eal_mp_remote_launch(lcore_f, ¶m, SKIP_MAIN)< 0)
app/test/test_ring_perf.c +1
-2return -1 ;/* start synchro and launch test on main */ -rte_atomic32_set (&synchro,1 ); +__atomic_store_n (&synchro,1 , __ATOMIC_RELAXED);lcore_f (¶m);rte_eal_mp_wait_lcore (); --2.17.1
PATCH 3/12 test/timer: use compiler atomic builtins for sync
In reply to Joyce KongConvert rte_atomic usages to compiler atomic built-ins for lcore_state and collisions sync.
--- app/test/test_timer.c | 28 ++++++++++++---------------- app/test/test_timer_secondary.c | 1 - 2 files changed, 12 insertions(+), 17 deletions(-)
app/test/test_timer.c +12 -16
@@ -102,7 +102,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_timer.h> #include <rte_random.h> #include <rte_malloc.h>
@@ -203,7 +202,7 @@ timer_stress_main_loop(__rte_unused void *arg)/* Need to synchronize worker lcores through multiple steps. */ enum {WORKER_WAITING =1 ,WORKER_RUN_SIGNAL ,WORKER_RUNNING ,WORKER_FINISHED }; -static rte_atomic16_t lcore_state[RTE_MAX_LCORE ]; +static uint16_t lcore_state[RTE_MAX_LCORE ];static void main_init_workers (void )
@@ -211,7 +210,7 @@ main_init_workers(void)unsigned i;RTE_LCORE_FOREACH_WORKER (i) { -rte_atomic16_set (&lcore_state[i],WORKER_WAITING ); +__atomic_store_n (&lcore_state[i],WORKER_WAITING , __ATOMIC_RELAXED); } }
@@ -221,11 +220,10 @@ main_start_workers(void)unsigned i;RTE_LCORE_FOREACH_WORKER (i) { -rte_atomic16_set (&lcore_state[i],WORKER_RUN_SIGNAL ); +__atomic_store_n (&lcore_state[i],WORKER_RUN_SIGNAL , __ATOMIC_RELAXED); }RTE_LCORE_FOREACH_WORKER (i) { -while (rte_atomic16_read (&lcore_state[i]) !=WORKER_RUNNING ) -rte_pause (); +rte_wait_until_equal_16 (&lcore_state[i],WORKER_RUNNING , __ATOMIC_RELAXED); } }
@@ -235,8 +233,7 @@ main_wait_for_workers(void)unsigned i;RTE_LCORE_FOREACH_WORKER (i) { -while (rte_atomic16_read (&lcore_state[i]) !=WORKER_FINISHED ) -rte_pause (); +rte_wait_until_equal_16 (&lcore_state[i],WORKER_FINISHED , __ATOMIC_RELAXED); } }
@@ -245,9 +242,8 @@ worker_wait_to_start(void) {unsigned lcore_id =rte_lcore_id (); -while (rte_atomic16_read (&lcore_state[lcore_id]) !=WORKER_RUN_SIGNAL ) -rte_pause (); -rte_atomic16_set (&lcore_state[lcore_id],WORKER_RUNNING ); +rte_wait_until_equal_16 (&lcore_state[lcore_id],WORKER_RUN_SIGNAL , __ATOMIC_RELAXED); +__atomic_store_n (&lcore_state[lcore_id],WORKER_RUNNING , __ATOMIC_RELAXED); } static void
@@ -255,7 +251,7 @@ worker_finish(void) {unsigned lcore_id =rte_lcore_id (); -rte_atomic16_set (&lcore_state[lcore_id],WORKER_FINISHED ); +__atomic_store_n (&lcore_state[lcore_id],WORKER_FINISHED , __ATOMIC_RELAXED); }
@@ -281,12 +277,12 @@ timer_stress2_main_loop(__rte_unused void *arg)unsigned int lcore_id =rte_lcore_id ();unsigned int main_lcore =rte_get_main_lcore ();int32_t my_collisions =0 ; -static rte_atomic32_t collisions; +static uint32_t collisions;if (lcore_id == main_lcore) { cb_count =0 ; test_failed =0 ; -rte_atomic32_set (&collisions,0 ); +__atomic_store_n (&collisions,0 , __ATOMIC_RELAXED);main_init_workers (); timers =rte_malloc (NULL ,sizeof (*timers) *NB_STRESS2_TIMERS ,0 );if (timers ==NULL ) {
@@ -315,7 +311,7 @@ timer_stress2_main_loop(__rte_unused void *arg) my_collisions++; }if (my_collisions !=0 ) -rte_atomic32_add (&collisions, my_collisions); +__atomic_fetch_add (&collisions, my_collisions, __ATOMIC_RELAXED);/* wait long enough for timers to expire */ rte_delay_ms (100 );
@@ -329,7 +325,7 @@ timer_stress2_main_loop(__rte_unused void *arg)/* now check that we get the right number of callbacks */ if (lcore_id == main_lcore) { - my_collisions =rte_atomic32_read (&collisions); + my_collisions =__atomic_load_n (&collisions, __ATOMIC_RELAXED);if (my_collisions !=0 )printf ("- %d timer reset collisions (OK)\n" , my_collisions);rte_timer_manage ();
app/test/test_timer_secondary.c +0 -1
@@ -9,7 +9,6 @@#include <rte_lcore.h> #include <rte_debug.h> #include <rte_memzone.h> -#include <rte_atomic.h> #include <rte_timer.h> #include <rte_cycles.h> #include <rte_mempool.h>
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v1 03/12] test/timer: use compiler atomic builtins for sync
<snip>
Quoted 44 lines
Subject: [PATCH v1 03/12] test/timer: use compiler atomic builtins for sync
Convert
rte_atomicusages to compiler atomic built-ins forlcore_stateand collisions sync.Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- app/test/test_timer.c | 28 ++++++++++++---------------- app/test/test_timer_secondary.c | 1 - 2 files changed, 12 insertions(+), 17 deletions(-)app/test/test_timer.c index renamed from app/test/test_timer.c +0
-0
a10b2fe9da..9a3e1b53e4100644app/test/test_timer.c +2
-2@@ -102,7 +102,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_timer.h> #include <rte_random.h> #include <rte_malloc.h> @@ -203,7 +202,7 @@ timer_stress_main_loop(__rte_unused void *arg)/* Need to synchronize worker lcores through multiple steps. */ enum {WORKER_WAITING =1 ,WORKER_RUN_SIGNAL ,WORKER_RUNNING , WORKER_FINISHED }; -static rte_atomic16_t lcore_state[RTE_MAX_LCORE]; +static uint16_t lcore_state[RTE_MAX_LCORE ];static void main_init_workers (void )@@ -211,7 +210,7 @@ main_init_workers(void)unsigned i;RTE_LCORE_FOREACH_WORKER (i) { -rte_atomic16_set (&lcore_state[i],WORKER_WAITING ); +__atomic_store_n (&lcore_state[i],WORKER_WAITING , __ATOMIC_RELAXED); } }
app/test/test_timer.c main_start_workers(void) · line 224
Quoted 6 lines
app/test/test_timer.c +2
-1@@ -221,11 +220,10 @@ main_start_workers(void)unsigned i;RTE_LCORE_FOREACH_WORKER (i) { -rte_atomic16_set (&lcore_state[i],WORKER_RUN_SIGNAL ); +__atomic_store_n (&lcore_state[i],WORKER_RUN_SIGNAL , +__ATOMIC_RELAXED);
We need to use RELEASE order here. When this function is called in timer_stress2_main_loop, the main_lcore is releasing memory operations to worker cores.
app/test/test_timer.c main_start_workers(void) · line 229
Quoted 7 lines
app/test/test_timer.c +2
-2}RTE_LCORE_FOREACH_WORKER (i) { -while (rte_atomic16_read (&lcore_state[i]) != WORKER_RUNNING) -rte_pause (); + rte_wait_until_equal_16(&lcore_state[i], WORKER_RUNNING, +__ATOMIC_RELAXED );
This should be ACQUIRE order.
app/test/test_timer.c main_wait_for_workers(void) · line 238
Quoted 12 lines
app/test/test_timer.c +2
-2} }@@ -235,8 +233,7 @@ main_wait_for_workers(void)unsigned i;RTE_LCORE_FOREACH_WORKER (i) { -while (rte_atomic16_read (&lcore_state[i]) != WORKER_FINISHED) -rte_pause (); + rte_wait_until_equal_16(&lcore_state[i], WORKER_FINISHED, +__ATOMIC_RELAXED );
We should use ACQUIRE here as the workers are releasing memory updates to the main lcore.
app/test/test_timer.c worker_wait_to_start(void) { · line 246
Quoted 12 lines
app/test/test_timer.c +1
-3} }@@ -245,9 +242,8 @@ worker_wait_to_start(void) {unsigned lcore_id =rte_lcore_id (); -while (rte_atomic16_read (&lcore_state[lcore_id]) != WORKER_RUN_SIGNAL) -rte_pause (); -rte_atomic16_set (&lcore_state[lcore_id],WORKER_RUNNING ); + rte_wait_until_equal_16(&lcore_state[lcore_id],WORKER_RUN_SIGNAL ,__ATOMIC_RELAXED );
Since the worker threads will use the memory operations that happened in main_lcore, we need ACQUIRE memory ordering here.
app/test/test_timer.c worker_wait_to_start(void) { · line 248
Quoted 2 lines
app/test/test_timer.c +2
-0+__atomic_store_n (&lcore_state[lcore_id],WORKER_RUNNING , +__ATOMIC_RELAXED);
This should be RELEASE memory order.
app/test/test_timer.c worker_finish(void) · line 255
Quoted 10 lines
app/test/test_timer.c +2
-1} static void@@ -255,7 +251,7 @@ worker_finish(void) {unsigned lcore_id =rte_lcore_id (); -rte_atomic16_set (&lcore_state[lcore_id],WORKER_FINISHED ); +__atomic_store_n (&lcore_state[lcore_id],WORKER_FINISHED , +__ATOMIC_RELAXED);
Should be RELEASE as workers are releasing updates to the main lcore.
Quoted 6 lines
app/test/test_timer.c +0
-0}@@ -281,12 +277,12 @@ timer_stress2_main_loop(__rte_unused void *arg)unsigned int lcore_id =rte_lcore_id ();unsigned int main_lcore =rte_get_main_lcore ();
app/test/test_timer.c timer_stress2_main_loop(__rte_unused void *arg) · line 286
Quoted 10 lines
app/test/test_timer.c +2
-2int32_t my_collisions =0 ; -static rte_atomic32_t collisions; +static uint32_t collisions;if (lcore_id == main_lcore) { cb_count =0 ; test_failed =0 ; -rte_atomic32_set (&collisions,0 ); +__atomic_store_n (&collisions,0 , __ATOMIC_RELAXED);main_init_workers ();
I think the existing code is probably incorrect in calling 'main_init_workers' in this function. This should be called outside of ' timer_stress2_main_loop' so that lcore_state is guaranteed to be initialized correctly before the threads are launched. Please call 'main_init_workers()' in ' test_timer' function.
Quoted 38 lines
app/test/test_timer.c +0
-0timers =rte_malloc (NULL ,sizeof (*timers) *NB_STRESS2_TIMERS ,0 );app/test/test_timer.c +1
-1if (timers ==NULL ) {@@ -315,7 +311,7 @@ timer_stress2_main_loop(__rte_unused void *arg) my_collisions++; }if (my_collisions !=0 ) -rte_atomic32_add (&collisions, my_collisions); +__atomic_fetch_add (&collisions, my_collisions, __ATOMIC_RELAXED);/* wait long enough for timers to expire */ app/test/test_timer.c +1
-1rte_delay_ms (100 );@@ -329,7 +325,7 @@ timer_stress2_main_loop(__rte_unused void *arg)/* now check that we get the right number of callbacks */ if (lcore_id == main_lcore) { - my_collisions =rte_atomic32_read (&collisions); + my_collisions =__atomic_load_n (&collisions, __ATOMIC_RELAXED);if (my_collisions !=0 ) printf("- %d timer reset collisions (OK)\n",
my_collisions);app/test/test_timer.c +0
-0rte_timer_manage ();(quoted diff) +0
-0
b/app/test/test_timer_secondary.cindex16a9f1878b..5795c97f07100644app/test/test_timer_secondary.c +0
-2@@ -9,7 +9,6 @@#include <rte_lcore.h> #include <rte_debug.h> #include <rte_memzone.h> -#include <rte_atomic.h> #include <rte_timer.h> #include <rte_cycles.h> #include <rte_mempool.h> --2.17.1
PATCH 4/12 test/stack_perf: use compiler atomics for lcore sync
In reply to Joyce KongConvert rte_atomic usages to compiler atomic built-ins for lcore sync in stack_perf test cases.
--- app/test/test_stack_perf.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
app/test/test_stack_perf.c +6 -8
@@ -6,7 +6,6 @@#include <stdio.h> #include <inttypes.h> -#include <rte_atomic.h> #include <rte_cycles.h> #include <rte_launch.h> #include <rte_pause.h>
@@ -24,7 +23,7 @@*/ static volatile unsigned int bulk_sizes[] = {8 ,MAX_BURST }; -static rte_atomic32_t lcore_barrier; +static uint32_t lcore_barrier;struct lcore_pair {unsigned int c1;
@@ -144,9 +143,8 @@ bulk_push_pop(void *p) s = args->s; size = args->sz; -rte_atomic32_sub (&lcore_barrier,1 ); -while (rte_atomic32_read (&lcore_barrier) !=0 ) -rte_pause (); +__atomic_fetch_sub (&lcore_barrier,1 , __ATOMIC_RELAXED); +rte_wait_until_equal_32 (&lcore_barrier,0 , __ATOMIC_RELAXED);uint64_t start =rte_rdtsc ();
@@ -175,7 +173,7 @@ run_on_core_pair(struct lcore_pair *cores, struct rte_stack *s,unsigned int i;for (i =0 ; i <RTE_DIM (bulk_sizes); i++) { -rte_atomic32_set (&lcore_barrier,2 ); +__atomic_store_n (&lcore_barrier,2 , __ATOMIC_RELAXED); args[0 ].sz = args[1 ].sz = bulk_sizes[i]; args[0 ].s = args[1 ].s = s;
@@ -208,7 +206,7 @@ run_on_n_cores(struct rte_stack *s, lcore_function_t fn, int n)int cnt =0 ;double avg; -rte_atomic32_set (&lcore_barrier, n); +__atomic_store_n (&lcore_barrier, n, __ATOMIC_RELAXED);RTE_LCORE_FOREACH_WORKER (lcore_id) {if (++cnt >= n)
@@ -302,7 +300,7 @@ __test_stack_perf(uint32_t flags)struct lcore_pair cores;struct rte_stack *s; -rte_atomic32_init (&lcore_barrier); +__atomic_store_n (&lcore_barrier,0 , __ATOMIC_RELAXED); s =rte_stack_create (STACK_NAME ,STACK_SIZE ,rte_socket_id (), flags);if (s ==NULL ) {
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v1 04/12] test/stack_perf: use compiler atomics for lcore sync
<snip>
Quoted 6 lines
Convert
rte_atomicusages to compiler atomic built-ins for lcore sync instack_perftest cases.Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>
Looks good
Quoted 69 lines
--- app/test/test_stack_perf.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)app/test/test_stack_perf.c index renamed from app/test/test_stack_perf.c +0
-0
4ee40d5d19..1eae00a334100644app/test/test_stack_perf.c +4
-6@@ -6,7 +6,6 @@#include <stdio.h> #include <inttypes.h> -#include <rte_atomic.h> #include <rte_cycles.h> #include <rte_launch.h> #include <rte_pause.h> @@ -24,7 +23,7 @@*/ static volatile unsigned int bulk_sizes[] = {8 ,MAX_BURST }; -static rte_atomic32_t lcore_barrier; +static uint32_t lcore_barrier;struct lcore_pair {unsigned int c1;@@ -144,9 +143,8 @@ bulk_push_pop(void *p) s = args->s; size = args->sz; -rte_atomic32_sub (&lcore_barrier,1 ); -while (rte_atomic32_read (&lcore_barrier) !=0 ) -rte_pause (); +__atomic_fetch_sub (&lcore_barrier,1 , __ATOMIC_RELAXED); +rte_wait_until_equal_32 (&lcore_barrier,0 , __ATOMIC_RELAXED);uint64_t start =rte_rdtsc ();@@ -175,7 +173,7 @@ run_on_core_pair(struct lcore_pair *cores, structrte_stack *s, unsigned int i;for (i =0 ; i <RTE_DIM (bulk_sizes); i++) { -rte_atomic32_set (&lcore_barrier,2 ); +__atomic_store_n (&lcore_barrier,2 , __ATOMIC_RELAXED); args[0 ].sz = args[1 ].sz = bulk_sizes[i];app/test/test_stack_perf.c +1
-1args[0 ].s = args[1 ].s = s;@@ -208,7 +206,7 @@ run_on_n_cores(struct rte_stack *s, lcore_function_t fn, int n)int cnt =0 ;double avg; -rte_atomic32_set (&lcore_barrier, n); +__atomic_store_n (&lcore_barrier, n, __ATOMIC_RELAXED);RTE_LCORE_FOREACH_WORKER (lcore_id) {app/test/test_stack_perf.c +1
-1if (++cnt >= n)@@ -302,7 +300,7 @@ __test_stack_perf(uint32_t flags)struct lcore_pair cores;struct rte_stack *s; -rte_atomic32_init (&lcore_barrier); +__atomic_store_n (&lcore_barrier,0 , __ATOMIC_RELAXED); s =rte_stack_create (STACK_NAME ,STACK_SIZE ,rte_socket_id (), flags);if (s == NULL) {
--
2.17.1
PATCH 5/12 test/bpf: use compiler atomics for calculation
In reply to Joyce KongConvert rte_atomic usages to compiler atomic built-ins for calculation in bpf test cases.
--- app/test/test_bpf.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
app/test/test_bpf.c +14 -14
@@ -1553,32 +1553,32 @@ test_xadd1_check(uint64_t rc, const void *arg)memset (&dfe,0 ,sizeof (dfe)); rv =1 ; -rte_atomic32_add ((rte_atomic32_t *)&dfe.u32, rv); -rte_atomic64_add ((rte_atomic64_t *)&dfe.u64, rv); +__atomic_fetch_add (&dfe.u32, rv, __ATOMIC_RELAXED); +__atomic_fetch_add (&dfe.u64, rv, __ATOMIC_RELAXED); rv =-1 ; -rte_atomic32_add ((rte_atomic32_t *)&dfe.u32, rv); -rte_atomic64_add ((rte_atomic64_t *)&dfe.u64, rv); +__atomic_fetch_add (&dfe.u32, rv, __ATOMIC_RELAXED); +__atomic_fetch_add (&dfe.u64, rv, __ATOMIC_RELAXED); rv = (int32_t )TEST_FILL_1 ; -rte_atomic32_add ((rte_atomic32_t *)&dfe.u32, rv); -rte_atomic64_add ((rte_atomic64_t *)&dfe.u64, rv); +__atomic_fetch_add (&dfe.u32, rv, __ATOMIC_RELAXED); +__atomic_fetch_add (&dfe.u64, rv, __ATOMIC_RELAXED); rv =TEST_MUL_1 ; -rte_atomic32_add ((rte_atomic32_t *)&dfe.u32, rv); -rte_atomic64_add ((rte_atomic64_t *)&dfe.u64, rv); +__atomic_fetch_add (&dfe.u32, rv, __ATOMIC_RELAXED); +__atomic_fetch_add (&dfe.u64, rv, __ATOMIC_RELAXED); rv =TEST_MUL_2 ; -rte_atomic32_add ((rte_atomic32_t *)&dfe.u32, rv); -rte_atomic64_add ((rte_atomic64_t *)&dfe.u64, rv); +__atomic_fetch_add (&dfe.u32, rv, __ATOMIC_RELAXED); +__atomic_fetch_add (&dfe.u64, rv, __ATOMIC_RELAXED); rv =TEST_JCC_2 ; -rte_atomic32_add ((rte_atomic32_t *)&dfe.u32, rv); -rte_atomic64_add ((rte_atomic64_t *)&dfe.u64, rv); +__atomic_fetch_add (&dfe.u32, rv, __ATOMIC_RELAXED); +__atomic_fetch_add (&dfe.u64, rv, __ATOMIC_RELAXED); rv =TEST_JCC_3 ; -rte_atomic32_add ((rte_atomic32_t *)&dfe.u32, rv); -rte_atomic64_add ((rte_atomic64_t *)&dfe.u64, rv); +__atomic_fetch_add (&dfe.u32, rv, __ATOMIC_RELAXED); +__atomic_fetch_add (&dfe.u64, rv, __ATOMIC_RELAXED);return cmp_res (__func__,1 , rc, &dfe, dft,sizeof (dfe)); }
Signature · 1 line
2.17.1
PATCH 6/12 test/func_reentrancy: use compiler atomic for data sync
In reply to Joyce KongConvert rte_atomic usages to compiler atomic built-ins for data sync in func_reentrancy test cases.
--- app/test/test_func_reentrancy.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
app/test/test_func_reentrancy.c +13 -14
@@ -20,7 +20,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_ring.h> #include <rte_mempool.h>
@@ -54,12 +53,12 @@ typedef void (*case_clean_t)(unsigned lcore_id);#define MAX_LCORES (RTE_MAX_MEMZONE / (MAX_ITER_MULTI * 4U)) -static rte_atomic32_t obj_count =RTE_ATOMIC32_INIT (0 ); -static rte_atomic32_t synchro =RTE_ATOMIC32_INIT (0 ); +static uint32_t obj_count; +static uint32_t synchro;#define WAIT_SYNCHRO_FOR_WORKERS () do { \ if (lcore_self != rte_get_main_lcore()) \ - while (rte_atomic32_read(&synchro) == 0); \ + rte_wait_until_equal_32(&synchro, 1, __ATOMIC_RELAXED); \ } while(0)/*
@@ -72,7 +71,7 @@ test_eal_init_once(__rte_unused void *arg)WAIT_SYNCHRO_FOR_WORKERS (); -rte_atomic32_set (&obj_count,1 );/* silent the check in the caller */ +__atomic_store_n (&obj_count,1 , __ATOMIC_RELAXED);/* silent the check in the caller */ if (rte_eal_init (0 ,NULL ) !=-1 )return -1 ;
@@ -112,7 +111,7 @@ ring_create_lookup(__rte_unused void *arg)for (i =0 ; i <MAX_ITER_ONCE ; i++) { rp =rte_ring_create ("fr_test_once" ,4096 ,SOCKET_ID_ANY ,0 );if (rp !=NULL ) -rte_atomic32_inc (&obj_count); +__atomic_fetch_add (&obj_count,1 , __ATOMIC_RELAXED); }/* create/lookup new ring several times */
@@ -176,7 +175,7 @@ mempool_create_lookup(__rte_unused void *arg) my_obj_init,NULL , SOCKET_ID_ANY, 0);if (mp !=NULL ) -rte_atomic32_inc (&obj_count); +__atomic_fetch_add (&obj_count,1 , __ATOMIC_RELAXED); }/* create/lookup new ring several times */
@@ -239,7 +238,7 @@ hash_create_free(__rte_unused void *arg)for (i =0 ; i <MAX_ITER_ONCE ; i++) { handle =rte_hash_create (&hash_params);if (handle !=NULL ) -rte_atomic32_inc (&obj_count); +__atomic_fetch_add (&obj_count,1 , __ATOMIC_RELAXED); }/* create mutiple times simultaneously */
@@ -303,7 +302,7 @@ fbk_create_free(__rte_unused void *arg)for (i =0 ; i <MAX_ITER_ONCE ; i++) { handle =rte_fbk_hash_create (&fbk_params);if (handle !=NULL ) -rte_atomic32_inc (&obj_count); +__atomic_fetch_add (&obj_count,1 , __ATOMIC_RELAXED); }/* create mutiple fbk tables simultaneously */
@@ -365,7 +364,7 @@ lpm_create_free(__rte_unused void *arg)for (i =0 ; i <MAX_ITER_ONCE ; i++) { lpm =rte_lpm_create ("fr_test_once" ,SOCKET_ID_ANY , &config);if (lpm !=NULL ) -rte_atomic32_inc (&obj_count); +__atomic_fetch_add (&obj_count,1 , __ATOMIC_RELAXED); }/* create mutiple fbk tables simultaneously */
@@ -427,8 +426,8 @@ launch_test(struct test_case *pt_case)if (pt_case->func ==NULL )return -1 ; -rte_atomic32_set (&obj_count,0 ); -rte_atomic32_set (&synchro,0 ); +__atomic_store_n (&obj_count,0 , __ATOMIC_RELAXED); +__atomic_store_n (&synchro,0 , __ATOMIC_RELAXED);RTE_LCORE_FOREACH_WORKER (lcore_id) {if (cores ==1 )
@@ -437,7 +436,7 @@ launch_test(struct test_case *pt_case)rte_eal_remote_launch (pt_case->func, pt_case->arg, lcore_id); } -rte_atomic32_set (&synchro,1 ); +__atomic_store_n (&synchro,1 , __ATOMIC_RELAXED);if (pt_case->func (pt_case->arg) <0 ) ret =-1 ;
@@ -454,7 +453,7 @@ launch_test(struct test_case *pt_case) pt_case->clean (lcore_id); } - count =rte_atomic32_read (&obj_count); + count =__atomic_load_n (&obj_count, __ATOMIC_RELAXED);if (count !=1 ) {printf ("%s: common object allocated %d times (should be 1)\n" , pt_case->name, count);
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v1 06/12] test/func_reentrancy: use compiler atomic for data sync
<snip>
Quoted 6 lines
Convert
rte_atomicusages to compiler atomic built-ins for data sync infunc_reentrancytest cases.Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>
Looks good.
Quoted 128 lines
--- app/test/test_func_reentrancy.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)app/test/test_func_reentrancy.c +4
-4@@ -20,7 +20,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_ring.h> #include <rte_mempool.h> @@ -54,12 +53,12 @@ typedef void (*case_clean_t)(unsigned lcore_id);#define MAX_LCORES (RTE_MAX_MEMZONE / (MAX_ITER_MULTI * 4U)) -static rte_atomic32_t obj_count = RTE_ATOMIC32_INIT(0); -staticrte_atomic32_t synchro =RTE_ATOMIC32_INIT (0 ); +static uint32_t obj_count; +static uint32_t synchro;#define WAIT_SYNCHRO_FOR_WORKERS () do { \ if (lcore_self != rte_get_main_lcore()) \ - while (rte_atomic32_read(&synchro) == 0); \ + rte_wait_until_equal_32(&synchro, 1, __ATOMIC_RELAXED); \ } while(0)/* @@ -72,7 +71,7 @@ test_eal_init_once(__rte_unused void *arg)WAIT_SYNCHRO_FOR_WORKERS (); -rte_atomic32_set (&obj_count,1 );/* silent the check in the caller */ +__atomic_store_n (&obj_count,1 , __ATOMIC_RELAXED);/* silent the check
app/test/test_func_reentrancy.c +2
-1+in the caller */ if (rte_eal_init (0 ,NULL ) !=-1 )return -1 ;@@ -112,7 +111,7 @@ ring_create_lookup(__rte_unused void *arg)for (i =0 ; i <MAX_ITER_ONCE ; i++) { rp =rte_ring_create ("fr_test_once" ,4096 ,SOCKET_ID_ANY ,0 );if (rp !=NULL ) -rte_atomic32_inc (&obj_count); +__atomic_fetch_add (&obj_count,1 , __ATOMIC_RELAXED); }/* create/lookup new ring several times */ @@ -176,7 +175,7 @@
mempool_create_lookup(__rte_unused void *arg)app/test/test_func_reentrancy.c +1
-1my_obj_init,NULL , SOCKET_ID_ANY, 0);if (mp !=NULL ) -rte_atomic32_inc (&obj_count); + __atomic_fetch_add(&obj_count, 1,
__ATOMIC_RELAXED);app/test/test_func_reentrancy.c +0
-0} /* create/lookup new ring several times */ @@ -239,7 +238,7 @@
hash_create_free(__rte_unused void *arg)app/test/test_func_reentrancy.c +1
-1for (i =0 ; i <MAX_ITER_ONCE ; i++) { handle =rte_hash_create (&hash_params);if (handle !=NULL ) -rte_atomic32_inc (&obj_count); + __atomic_fetch_add(&obj_count, 1,
__ATOMIC_RELAXED);app/test/test_func_reentrancy.c +0
-0} /* create mutiple times simultaneously */ @@ -303,7 +302,7 @@
fbk_create_free(__rte_unused void *arg)app/test/test_func_reentrancy.c +1
-1for (i =0 ; i <MAX_ITER_ONCE ; i++) { handle =rte_fbk_hash_create (&fbk_params);if (handle !=NULL ) -rte_atomic32_inc (&obj_count); + __atomic_fetch_add(&obj_count, 1,
__ATOMIC_RELAXED);app/test/test_func_reentrancy.c +0
-0} /* create mutiple fbk tables simultaneously */ @@ -365,7 +364,7 @@
lpm_create_free(__rte_unused void *arg)app/test/test_func_reentrancy.c +0
-0for (i =0 ; i <MAX_ITER_ONCE ; i++) { lpm = rte_lpm_create("fr_test_once", SOCKET_ID_ANY,&config);
app/test/test_func_reentrancy.c +1
-1if (lpm !=NULL ) -rte_atomic32_inc (&obj_count); + __atomic_fetch_add(&obj_count, 1,
__ATOMIC_RELAXED);app/test/test_func_reentrancy.c +0
-0} /* create mutiple fbk tables simultaneously */ @@ -427,8 +426,8 @@
launch_test(struct test_case *pt_case)app/test/test_func_reentrancy.c +3
-3if (pt_case->func ==NULL )return -1 ; -rte_atomic32_set (&obj_count,0 ); -rte_atomic32_set (&synchro,0 ); +__atomic_store_n (&obj_count,0 , __ATOMIC_RELAXED); +__atomic_store_n (&synchro,0 , __ATOMIC_RELAXED);RTE_LCORE_FOREACH_WORKER (lcore_id) {if (cores ==1 )@@ -437,7 +436,7 @@ launch_test(struct test_case *pt_case)rte_eal_remote_launch (pt_case->func, pt_case->arg, lcore_id); } -rte_atomic32_set (&synchro,1 ); +__atomic_store_n (&synchro,1 , __ATOMIC_RELAXED);if (pt_case->func (pt_case->arg) <0 )app/test/test_func_reentrancy.c +1
-1ret =-1 ;@@ -454,7 +453,7 @@ launch_test(struct test_case *pt_case) pt_case->clean (lcore_id); } - count =rte_atomic32_read (&obj_count); + count =__atomic_load_n (&obj_count, __ATOMIC_RELAXED);if (count !=1 ) { printf("%s: common object allocated %d times (should be 1)\n",
pt_case->name, count);
--
2.17.1
PATCH 7/12 app/eventdev: use compiler atomic builtins for packets sync
In reply to Joyce KongConvert rte_atomic usages to compiler atomic built-ins for outstanding_pkts sync in eventdev cases.
--- app/test-eventdev/evt_main.c | 1 - app/test-eventdev/test_order_atq.c | 4 ++-- app/test-eventdev/test_order_common.c | 4 ++-- app/test-eventdev/test_order_common.h | 8 ++++---- app/test-eventdev/test_order_queue.c | 4 ++-- 5 files changed, 10 insertions(+), 11 deletions(-)
app/test-eventdev/evt_main.c +0 -1
@@ -6,7 +6,6 @@#include <unistd.h> #include <signal.h> -#include <rte_atomic.h> #include <rte_debug.h> #include <rte_eal.h> #include <rte_eventdev.h>
app/test-eventdev/test_order_atq.c +2 -2
@@ -28,7 +28,7 @@ order_atq_worker(void *arg, const bool flow_id_cap)uint16_t event =rte_event_dequeue_burst (dev_id, port, &ev,1 ,0 );if (!event) { -if (rte_atomic64_read (outstand_pkts) <=0 ) +if (__atomic_load_n (outstand_pkts, __ATOMIC_RELAXED) <=0 )break ;rte_pause ();continue ;
@@ -64,7 +64,7 @@ order_atq_worker_burst(void *arg, const bool flow_id_cap) BURST_SIZE, 0);if (nb_rx ==0 ) { -if (rte_atomic64_read (outstand_pkts) <=0 ) +if (__atomic_load_n (outstand_pkts, __ATOMIC_RELAXED) <=0 )break ;rte_pause ();continue ;
app/test-eventdev/test_order_common.c +2 -2
@@ -187,7 +187,7 @@ order_test_setup(struct evt_test *test, struct evt_options *opt)evt_err ("failed to allocate t->expected_flow_seq memory" ); goto exp_nomem; } -rte_atomic64_set (&t->outstand_pkts, opt->nb_pkts); +__atomic_store_n (&t->outstand_pkts, opt->nb_pkts, __ATOMIC_RELAXED); t->err = false; t->nb_pkts = opt->nb_pkts; t->nb_flows = opt->nb_flows;
@@ -294,7 +294,7 @@ order_launch_lcores(struct evt_test *test, struct evt_options *opt,while (t->err == false) {uint64_t new_cycles =rte_get_timer_cycles (); -int64_t remaining =rte_atomic64_read (&t->outstand_pkts); +int64_t remaining =__atomic_load_n (&t->outstand_pkts, __ATOMIC_RELAXED);if (remaining <=0 ) { t->result =EVT_TEST_SUCCESS ;
app/test-eventdev/test_order_common.h +4 -4
@@ -48,7 +48,7 @@ struct test_order {* The atomic_* is an expensive operation,Since it is a functional test, * We are using the atomic_ operation to reduce the code complexity. */ -rte_atomic64_t outstand_pkts; +uint64_t outstand_pkts;enum evt_test_result result;uint32_t nb_flows;uint64_t nb_pkts;
@@ -95,7 +95,7 @@ static __rte_always_inline void order_process_stage_1(struct test_order *const t, struct rte_event *const ev, const uint32_t nb_flows, uint32_t *const expected_flow_seq, - rte_atomic64_t *const outstand_pkts) + uint64_t *const outstand_pkts) { const uint32_t flow = (uintptr_t)ev->mbuf % nb_flows;/* compare the seqn against expected value */
@@ -113,7 +113,7 @@ order_process_stage_1(struct test_order *const t,*/ expected_flow_seq[flow]++;rte_pktmbuf_free (ev->mbuf); -rte_atomic64_sub (outstand_pkts,1 ); +__atomic_fetch_sub (outstand_pkts,1 , __ATOMIC_RELAXED); }static __rte_always_inline void
@@ -132,7 +132,7 @@ order_process_stage_invalid(struct test_order *const t,const uint8_t port = w->port_id;\const uint32_t nb_flows = t->nb_flows;\uint32_t *expected_flow_seq = t->expected_flow_seq;\ -rte_atomic64_t *outstand_pkts = &t->outstand_pkts;\ +uint64_t *outstand_pkts = &t->outstand_pkts;\if (opt->verbose_level >1 )\printf ("%s(): lcore %d dev_id %d port=%d\n" ,\ __func__,rte_lcore_id (), dev_id, port)
app/test-eventdev/test_order_queue.c +2 -2
@@ -28,7 +28,7 @@ order_queue_worker(void *arg, const bool flow_id_cap)uint16_t event =rte_event_dequeue_burst (dev_id, port, &ev,1 ,0 );if (!event) { -if (rte_atomic64_read (outstand_pkts) <=0 ) +if (__atomic_load_n (outstand_pkts, __ATOMIC_RELAXED) <=0 )break ;rte_pause ();continue ;
@@ -64,7 +64,7 @@ order_queue_worker_burst(void *arg, const bool flow_id_cap) BURST_SIZE, 0);if (nb_rx ==0 ) { -if (rte_atomic64_read (outstand_pkts) <=0 ) +if (__atomic_load_n (outstand_pkts, __ATOMIC_RELAXED) <=0 )break ;rte_pause ();continue ;
Signature · 1 line
2.17.1
RE: [PATCH v1 07/12] app/eventdev: use compiler atomic builtins for packets sync
<snip>
Quoted 2 lines
Subject: [PATCH v1 07/12] app/eventdev: use compiler atomic builtins for packets sync
How about the following:
app/eventdev: use compiler atomic builtins for shared data synchronization
Quoted 14 lines
Convert
rte_atomicusages to compiler atomic built-ins foroutstanding_pktssync in eventdev cases.Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- app/test-eventdev/evt_main.c | 1 - app/test-eventdev/test_order_atq.c | 4 ++-- app/test-eventdev/test_order_common.c | 4 ++-- app/test- eventdev/test_order_common.h | 8 ++++---- app/test- eventdev/test_order_queue.c | 4 ++-- 5 files changed, 10 insertions(+), 11 deletions(-)
<snip>
Quoted 33 lines
app/test- renamed from app/test-eventdev/test_order_common.h +0
-0
eventdev/test_order_common.h
index cd9d6009ec..1507265928 100644app/test-eventdev/test_order_common.h +2
-2@@ -48,7 +48,7 @@ struct test_order {* The atomic_* is an expensive operation,Since it is a functional test, * We are using the atomic_ operation to reduce the code complexity. */ -rte_atomic64_t outstand_pkts; +uint64_t outstand_pkts;enum evt_test_result result;uint32_t nb_flows;uint64_t nb_pkts;@@ -95,7 +95,7 @@ static __rte_always_inline void order_process_stage_1(struct test_order *const t, struct rte_event *const ev, const uint32_t nb_flows, uint32_t *const expected_flow_seq, - rte_atomic64_t *const outstand_pkts) + uint64_t *const outstand_pkts) { const uint32_t flow = (uintptr_t)ev->mbuf % nb_flows; /* compare the seqn against expected value */ @@ -113,7 +113,7@@ order_process_stage_1(struct
test_order*const t,app/test-eventdev/test_order_common.h +1
-1*/ expected_flow_seq[flow]++;rte_pktmbuf_free (ev->mbuf); -rte_atomic64_sub (outstand_pkts,1 ); +__atomic_fetch_sub (outstand_pkts,1 , __ATOMIC_RELAXED); }static __rte_always_inline void
app/test-eventdev/test_order_common.h order_process_stage_invalid(struct test_order *const · line 136
Quoted 6 lines
app/test-eventdev/test_order_common.h +1
-1@@ -132,7 +132,7 @@ order_process_stage_invalid(struct test_order *const t, const uint8_t port = w->port_id;\const uint32_t nb_flows = t->nb_flows;\uint32_t *expected_flow_seq = t->expected_flow_seq;\ -rte_atomic64_t *outstand_pkts = &t->outstand_pkts;\ +uint64_t *outstand_pkts = &t->outstand_pkts;\
We could use the atomic built-in to set this? We have been doing that in other places.
Quoted 3 lines
app/test-eventdev/test_order_common.h +0
-0if (opt->verbose_level >1 )\ printf("%s(): lcore %d dev_id %d port=%d\n",\
__func__,rte_lcore_id(),dev_id, port) diff --git
<snip>
RE: [PATCH v1 07/12] app/eventdev: use compiler atomic builtins for packets sync
Quoted 7 lines
<snip>
Quoted 2 lines
Subject: [PATCH v1 07/12] app/eventdev: use compiler atomic builtins for packets sync
How about the following:
app/eventdev: use compiler atomic builtins for shared data synchronization
Yes, please see next version.
Quoted 38 lines
Quoted 4 lines
Convert
rte_atomicusages to compiler atomic built-ins foroutstanding_pktssync in eventdev cases.<snip>
Quoted 14 lines
app/test- renamed from app/test-eventdev/test_order_common.h +0
-0
eventdev/test_order_common.hindex cd9d6009ec..1507265928 100644app/test-eventdev/test_order_common.h +1
-1@@ -48,7 +48,7 @@ struct test_order {* The atomic_* is an expensive operation,Since it is a functional test, * We are using the atomic_ operation to reduce the code complexity. */ -rte_atomic64_t outstand_pkts; +uint64_t outstand_pkts;enum evt_test_result result;uint32_t nb_flows;uint64_t nb_pkts;app/test-eventdev/test_order_common.h static __rte_always_inline void · line 101
Quoted 8 lines
app/test-eventdev/test_order_common.h +1
-1@@ -95,7 +95,7 @@ static __rte_always_inline void order_process_stage_1(struct test_order *const t, struct rte_event *const ev, const uint32_t nb_flows, uint32_t *const expected_flow_seq, - rte_atomic64_t *const outstand_pkts) + uint64_t *const outstand_pkts) { const uint32_t flow = (uintptr_t)ev->mbuf % nb_flows; /* compare the seqn against expected value */ @@ -113,7 +113,7@@
Quoted 8 lines
order_process_stage_1(struct
test_order*const t,app/test-eventdev/test_order_common.h +1
-1*/ expected_flow_seq[flow]++;rte_pktmbuf_free (ev->mbuf); -rte_atomic64_sub (outstand_pkts,1 ); +__atomic_fetch_sub (outstand_pkts,1 , __ATOMIC_RELAXED); }
Quoted 10 lines
app/test-eventdev/test_order_common.h order_process_stage_invalid(struct test_order · line 136
Quoted 8 lines
static
__rte_always_inlinevoidapp/test-eventdev/test_order_common.h +1
-1@@ -132,7 +132,7 @@ order_process_stage_invalid(struct test_order *const t,const uint8_t port = w->port_id;\const uint32_t nb_flows = t->nb_flows;\uint32_t *expected_flow_seq = t->expected_flow_seq;\ -rte_atomic64_t *outstand_pkts = &t->outstand_pkts;\ +uint64_t *outstand_pkts = &t->outstand_pkts;\We could use the atomic built-in to set this? We have been doing that in other places.
Here is an address operation, so atomic built-in may not be used.
Quoted 6 lines
Quoted 4 lines
app/test-eventdev/test_order_common.h +0
-0if (opt->verbose_level >1 )\ printf("%s(): lcore %d dev_id %d port=%d\n",\
__func__,rte_lcore_id(),dev_id, port) diff --git<snip>
PATCH 8/12 app/crypto: use compiler atomic builtins for display sync
In reply to Joyce KongCovert rte_atomic_test_and_set usage to compiler atomic CAS operation for display sync in crypto cases.
--- app/test-crypto-perf/cperf_test_latency.c | 6 ++++-- app/test-crypto-perf/cperf_test_pmd_cyclecount.c | 9 ++++++--- app/test-crypto-perf/cperf_test_throughput.c | 9 ++++++--- app/test-crypto-perf/cperf_test_verify.c | 9 ++++++--- 4 files changed, 22 insertions(+), 11 deletions(-)
app/test-crypto-perf/cperf_test_latency.c +4 -2
@@ -126,7 +126,7 @@ cperf_latency_test_runner(void *arg)uint8_t burst_size_idx =0 ;uint32_t imix_idx =0 ; -static rte_atomic16_t display_once =RTE_ATOMIC16_INIT (0 ); +static uint16_t display_once;if (ctx ==NULL )return 0 ;
@@ -308,7 +308,9 @@ cperf_latency_test_runner(void *arg) time_min = tunit*(double )(tsc_min) / tsc_hz;if (ctx->options->csv) { -if (rte_atomic16_test_and_set (&display_once)) +uint16_t exp =0 ; +if (__atomic_compare_exchange_n (&display_once, &exp,1 ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED))printf ("\n# lcore, Buffer Size, Burst Size, Pakt Seq #, " "cycles, time (us)" );
app/test-crypto-perf/cperf_test_pmd_cyclecount.c +6 -3
@@ -404,7 +404,7 @@ cperf_pmd_cyclecount_test_runner(void *test_ctx) state.lcore =rte_lcore_id (); state.linearize =0 ; -static rte_atomic16_t display_once =RTE_ATOMIC16_INIT (0 ); +static uint16_t display_once;static bool warmup = true;/*
@@ -449,8 +449,10 @@ cperf_pmd_cyclecount_test_runner(void *test_ctx)continue ; } +uint16_t exp =0 ;if (!opts->csv) { -if (rte_atomic16_test_and_set (&display_once)) +if (__atomic_compare_exchange_n (&display_once, &exp,1 ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) printf(PRETTY_HDR_FMT, "lcore id", "Buf Size", "Burst Size", "Enqueued", "Dequeued", "Enq Retries",
@@ -466,7 +468,8 @@ cperf_pmd_cyclecount_test_runner(void *test_ctx) state.cycles_per_enq, state.cycles_per_deq); }else { -if (rte_atomic16_test_and_set (&display_once)) +if (__atomic_compare_exchange_n (&display_once, &exp,1 ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) printf(CSV_HDR_FMT, "# lcore id", "Buf Size", "Burst Size", "Enqueued", "Dequeued", "Enq Retries",
app/test-crypto-perf/cperf_test_throughput.c +6 -3
@@ -106,7 +106,7 @@ cperf_throughput_test_runner(void *test_ctx)uint8_t burst_size_idx =0 ;uint32_t imix_idx =0 ; -static rte_atomic16_t display_once =RTE_ATOMIC16_INIT (0 ); +static uint16_t display_once;struct rte_crypto_op *ops[ctx->options->max_burst_size];struct rte_crypto_op *ops_processed[ctx->options->max_burst_size];
@@ -272,8 +272,10 @@ cperf_throughput_test_runner(void *test_ctx)double cycles_per_packet = ((double )tsc_duration / ctx->options->total_ops); +uint16_t exp =0 ;if (!ctx->options->csv) { -if (rte_atomic16_test_and_set (&display_once)) +if (__atomic_compare_exchange_n (&display_once, &exp,1 ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) printf("%12s%12s%12s%12s%12s%12s%12s%12s%12s%12s\n\n", "lcore id", "Buf Size", "Burst Size", "Enqueued", "Dequeued", "Failed Enq",
@@ -293,7 +295,8 @@ cperf_throughput_test_runner(void *test_ctx) throughput_gbps, cycles_per_packet); }else { -if (rte_atomic16_test_and_set (&display_once)) +if (__atomic_compare_exchange_n (&display_once, &exp,1 ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED))printf ("#lcore id,Buffer Size(B)," "Burst Size,Enqueued,Dequeued,Failed Enq," "Failed Deq,Ops(Millions),Throughput(Gbps),"
app/test-crypto-perf/cperf_test_verify.c +6 -3
@@ -241,7 +241,7 @@ cperf_verify_test_runner(void *test_ctx)uint64_t ops_deqd =0 , ops_deqd_total =0 , ops_deqd_failed =0 ;uint64_t ops_failed =0 ; -static rte_atomic16_t display_once =RTE_ATOMIC16_INIT (0 ); +static uint16_t display_once;uint64_t i;uint16_t ops_unused =0 ;
@@ -383,8 +383,10 @@ cperf_verify_test_runner(void *test_ctx) ops_deqd_total += ops_deqd; } +uint16_t exp =0 ;if (!ctx->options->csv) { -if (rte_atomic16_test_and_set (&display_once)) +if (__atomic_compare_exchange_n (&display_once, &exp,1 ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) printf("%12s%12s%12s%12s%12s%12s%12s%12s\n\n", "lcore id", "Buf Size", "Burst size", "Enqueued", "Dequeued", "Failed Enq",
@@ -401,7 +403,8 @@ cperf_verify_test_runner(void *test_ctx) ops_deqd_failed, ops_failed); }else { -if (rte_atomic16_test_and_set (&display_once)) +if (__atomic_compare_exchange_n (&display_once, &exp,1 ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED))printf ("\n# lcore id, Buffer Size(B), " "Burst Size,Enqueued,Dequeued,Failed Enq," "Failed Deq,Failed Ops\n" );
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v1 08/12] app/crypto: use compiler atomic builtins for display sync
<snip>
Quoted 2 lines
Covert
rte_atomic_test_and_setusage to compiler atomic CAS operation for
^^^^^^ Convert
Quoted 4 lines
display sync in crypto cases.
Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>
With the above typo fixed,
Quoted 160 lines
--- app/test-crypto-perf/cperf_test_latency.c | 6 ++++-- app/test-crypto-perf/cperf_test_pmd_cyclecount.c | 9 ++++++--- app/test-crypto-perf/cperf_test_throughput.c | 9 ++++++--- app/test-crypto-perf/cperf_test_verify.c | 9 ++++++--- 4 files changed, 22 insertions(+), 11 deletions(-)app/test-crypto- renamed from app/test-crypto-perf/cperf_test_latency.c +0
-0
perf/cperf_test_latency.c
index159fe8492b..5e73c75fba100644app/test-crypto-perf/cperf_test_latency.c +4
-2@@ -126,7 +126,7 @@ cperf_latency_test_runner(void *arg)uint8_t burst_size_idx =0 ;uint32_t imix_idx =0 ; -static rte_atomic16_t display_once =RTE_ATOMIC16_INIT (0 ); +static uint16_t display_once;if (ctx ==NULL )return 0 ;@@ -308,7 +308,9 @@ cperf_latency_test_runner(void *arg) time_min = tunit*(double )(tsc_min) / tsc_hz;if (ctx->options->csv) { -if (rte_atomic16_test_and_set (&display_once)) +uint16_t exp =0 ; +if (__atomic_compare_exchange_n (&display_once, &exp,1 ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) printf("\n# lcore, Buffer Size, Burst Size, PaktSeq #, "
app/test-crypto-perf/cperf_test_latency.c +0
-0"cycles, time (us)");app/test- renamed from app/test-crypto-perf/cperf_test_pmd_cyclecount.c +0
-0
crypto-perf/cperf_test_pmd_cyclecount.c
index844659aeca..a1de334efb100644app/test-crypto-perf/cperf_test_pmd_cyclecount.c +4
-2@@ -404,7 +404,7 @@ cperf_pmd_cyclecount_test_runner(void *test_ctx) state.lcore =rte_lcore_id (); state.linearize =0 ; -static rte_atomic16_t display_once =RTE_ATOMIC16_INIT (0 ); +static uint16_t display_once;static bool warmup = true;/* @@ -449,8 +449,10 @@ cperf_pmd_cyclecount_test_runner(void *test_ctx)continue ; } +uint16_t exp =0 ;if (!opts->csv) { -if (rte_atomic16_test_and_set (&display_once)) +if (__atomic_compare_exchange_n (&display_once, &exp,1 ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) printf(PRETTY_HDR_FMT, "lcore id", "BufSize",
app/test-crypto-perf/cperf_test_pmd_cyclecount.c +2
-1"Burst Size" ,"Enqueued" , "Dequeued", "Enq Retries",@@ -466,7 +468,8 @@ cperf_pmd_cyclecount_test_runner(void *test_ctx) state.cycles_per_enq, state.cycles_per_deq); }else { -if (rte_atomic16_test_and_set (&display_once)) +if (__atomic_compare_exchange_n (&display_once, &exp,1 ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) printf(CSV_HDR_FMT, "# lcore id", "Buf Size",app/test-crypto-perf/cperf_test_pmd_cyclecount.c +0
-0"Burst Size" ,"Enqueued" , "Dequeued", "Enq Retries",app/test-crypto- renamed from app/test-crypto-perf/cperf_test_throughput.c +0
-0
perf/cperf_test_throughput.c
indexf6eb8cf259..1407007c6e100644app/test-crypto-perf/cperf_test_throughput.c +4
-2@@ -106,7 +106,7 @@ cperf_throughput_test_runner(void *test_ctx)uint8_t burst_size_idx =0 ;uint32_t imix_idx =0 ; -static rte_atomic16_t display_once =RTE_ATOMIC16_INIT (0 ); +static uint16_t display_once;struct rte_crypto_op *ops[ctx->options->max_burst_size];struct rte_crypto_op *ops_processed[ctx->options->max_burst_size];@@ -272,8 +272,10 @@ cperf_throughput_test_runner(void *test_ctx)double cycles_per_packet = ((double )tsc_duration / ctx->options->total_ops); +uint16_t exp =0 ;if (!ctx->options->csv) { -if (rte_atomic16_test_and_set (&display_once)) +if (__atomic_compare_exchange_n (&display_once, &exp,1 ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED))printf("%12s%12s%12s%12s%12s%12s%12s%12s%12s%12s\n\n",app/test-crypto-perf/cperf_test_throughput.c +0
-0"lcore id" ,"Buf Size" ,"Burst Size" , "Enqueued", "Dequeued", "FailedEnq", @@ -293,7 +295,8 @@
cperf_throughput_test_runner(void *test_ctx)app/test-crypto-perf/cperf_test_throughput.c +1
-1throughput_gbps, cycles_per_packet); }else { -if (rte_atomic16_test_and_set (&display_once)) + if (__atomic_compare_exchange_n(&display_once,&exp, 1, 0,
app/test-crypto-perf/cperf_test_throughput.c +1
-0+ __ATOMIC_RELAXED,
__ATOMIC_RELAXED))app/test-crypto-perf/cperf_test_throughput.c +0
-0printf("#lcore id,Buffer Size(B)," "BurstSize,Enqueued,Dequeued,Failed Enq,"
"Failed
Deq,Ops(Millions),Throughput(Gbps),"app/test-crypto- renamed from app/test-crypto-perf/cperf_test_verify.c +0
-0
perf/cperf_test_verify.c
index2939aeaa93..0c053ad3c0100644app/test-crypto-perf/cperf_test_verify.c +4
-2@@ -241,7 +241,7 @@ cperf_verify_test_runner(void *test_ctx)uint64_t ops_deqd =0 , ops_deqd_total =0 , ops_deqd_failed =0 ;uint64_t ops_failed =0 ; -static rte_atomic16_t display_once =RTE_ATOMIC16_INIT (0 ); +static uint16_t display_once;uint64_t i;uint16_t ops_unused =0 ;@@ -383,8 +383,10 @@ cperf_verify_test_runner(void *test_ctx) ops_deqd_total += ops_deqd; } +uint16_t exp =0 ;if (!ctx->options->csv) { -if (rte_atomic16_test_and_set (&display_once)) +if (__atomic_compare_exchange_n (&display_once, &exp,1 ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) printf("%12s%12s%12s%12s%12s%12s%12s%12s\n\n",app/test-crypto-perf/cperf_test_verify.c +0
-0"lcore id" ,"Buf Size" ,"Burst size" , "Enqueued", "Dequeued", "Failed Enq", @@ -401,7 +403,8 @@
cperf_verify_test_runner(void *test_ctx)app/test-crypto-perf/cperf_test_verify.c +1
-1ops_deqd_failed, ops_failed); }else { -if (rte_atomic16_test_and_set (&display_once)) + if (__atomic_compare_exchange_n(&display_once, &exp, 1,0,
app/test-crypto-perf/cperf_test_verify.c +1
-1+ __ATOMIC_RELAXED, __ATOMIC_RELAXED))printf ("\n# lcore id, Buffer Size(B), " "Burst Size,Enqueued,Dequeued,Failed Enq," "Failed Deq,Failed Ops\n" ); --2.17.1
PATCH 9/12 app/compress: use compiler atomic builtins for display sync
In reply to Joyce KongConvert rte_atomic_test_and_set usage to compiler atomic CAS operation for display sync.
--- app/test-compress-perf/comp_perf_test_common.h | 2 +- app/test-compress-perf/comp_perf_test_cyclecount.c | 10 +++++++--- app/test-compress-perf/comp_perf_test_throughput.c | 11 ++++++++--- app/test-compress-perf/comp_perf_test_verify.c | 6 ++++-- 4 files changed, 20 insertions(+), 9 deletions(-)
app/test-compress-perf/comp_perf_test_common.h +1 -1
@@ -14,7 +14,7 @@ struct cperf_mem_resources {uint16_t qp_id;uint8_t lcore_id; -rte_atomic16_t print_info_once; +uint16_t print_info_once;uint32_t total_bufs;uint8_t *compressed_data;
app/test-compress-perf/comp_perf_test_cyclecount.c +7 -3
@@ -468,7 +468,7 @@ cperf_cyclecount_test_runner(void *test_ctx)struct cperf_cyclecount_ctx *ctx = test_ctx;struct comp_test_data *test_data = ctx->ver.options;uint32_t lcore =rte_lcore_id (); -static rte_atomic16_t display_once =RTE_ATOMIC16_INIT (0 ); +static uint16_t display_once;static rte_spinlock_t print_spinlock;int i;
@@ -488,10 +488,12 @@ cperf_cyclecount_test_runner(void *test_ctx) ctx->ver.mem.lcore_id = lcore; +uint16_t exp =0 ;/* * printing information about current compression thread */ -if (rte_atomic16_test_and_set (&ctx->ver.mem.print_info_once)) +if (__atomic_compare_exchange_n (&ctx->ver.mem.print_info_once, &exp, +1 ,0 , __ATOMIC_RELAXED, __ATOMIC_RELAXED))printf (" lcore: %u," " driver name: %s," " device name: %s,"
@@ -547,8 +549,10 @@ cperf_cyclecount_test_runner(void *test_ctx) duration_setup_per_op = ctx->duration_op / (ctx->ver.mem.total_bufs * test_data->num_iter); + exp =0 ;/* R E P O R T processing */ -if (rte_atomic16_test_and_set (&display_once)) { +if (__atomic_compare_exchange_n (&display_once, &exp,1 ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) {rte_spinlock_lock (&print_spinlock);
app/test-compress-perf/comp_perf_test_throughput.c +8 -3
@@ -329,15 +329,18 @@ cperf_throughput_test_runner(void *test_ctx)struct cperf_benchmark_ctx *ctx = test_ctx;struct comp_test_data *test_data = ctx->ver.options;uint32_t lcore =rte_lcore_id (); -static rte_atomic16_t display_once =RTE_ATOMIC16_INIT (0 ); +static uint16_t display_once;int i, ret =EXIT_SUCCESS ; ctx->ver.mem.lcore_id = lcore; +uint16_t exp =0 ;/* * printing information about current compression thread */ -if (rte_atomic16_test_and_set (&ctx->ver.mem.print_info_once)) +if (__atomic_compare_exchange_n (&ctx->ver.mem.print_info_once, &exp, +1 ,0 , __ATOMIC_RELAXED, __ATOMIC_RELAXED)) +printf (" lcore: %u," " driver name: %s," " device name: %s,"
@@ -391,7 +394,9 @@ cperf_throughput_test_runner(void *test_ctx) ctx->decomp_gbps =rte_get_tsc_hz () / ctx->decomp_tsc_byte *8 /1000000000 ; -if (rte_atomic16_test_and_set (&display_once)) { + exp =0 ; +if (__atomic_compare_exchange_n (&display_once, &exp,1 ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) {printf ("\n%12s%6s%12s%17s%15s%16s\n" ,"lcore id" ,"Level" ,"Comp size" ,"Comp ratio [%]" ,"Comp [Gbps]" ,"Decomp [Gbps]" );
app/test-compress-perf/comp_perf_test_verify.c +4 -2
@@ -388,7 +388,7 @@ cperf_verify_test_runner(void *test_ctx)struct cperf_verify_ctx *ctx = test_ctx;struct comp_test_data *test_data = ctx->options;int ret =EXIT_SUCCESS ; -static rte_atomic16_t display_once =RTE_ATOMIC16_INIT (0 ); +static uint16_t display_once;uint32_t lcore =rte_lcore_id (); ctx->mem.lcore_id = lcore;
@@ -428,7 +428,9 @@ cperf_verify_test_runner(void *test_ctx) test_data->input_data_sz *100 ;if (!ctx->silent) { -if (rte_atomic16_test_and_set (&display_once)) { +uint16_t exp =0 ; +if (__atomic_compare_exchange_n (&display_once, &exp,1 ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) {printf ("%12s%6s%12s%17s\n" ,"lcore id" ,"Level" ,"Comp size" ,"Comp ratio [%]" ); }
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v1 09/12] app/compress: use compiler atomic builtins for display sync
<snip>
Quoted 58 lines
Convert
rte_atomic_test_and_setusage to compiler atomic CAS operation for display sync.Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- app/test-compress-perf/comp_perf_test_common.h | 2 +- app/test-compress-perf/comp_perf_test_cyclecount.c | 10 +++++++--- app/test-compress-perf/comp_perf_test_throughput.c | 11 ++++++++--- app/test-compress-perf/comp_perf_test_verify.c | 6 ++++-- 4 files changed, 20 insertions(+), 9 deletions(-)app/test- renamed from app/test-compress-perf/comp_perf_test_common.h +0
-0
compress-perf/comp_perf_test_common.h
index72705c6a2b..d039e5a29a100644app/test-compress-perf/comp_perf_test_common.h +1
-1@@ -14,7 +14,7 @@ struct cperf_mem_resources {uint16_t qp_id;uint8_t lcore_id; -rte_atomic16_t print_info_once; +uint16_t print_info_once;uint32_t total_bufs;uint8_t *compressed_data;app/test- renamed from app/test-compress-perf/comp_perf_test_cyclecount.c +0
-0
compress-perf/comp_perf_test_cyclecount.c
index55559a7d5a..e002e53bdf100644app/test-compress-perf/comp_perf_test_cyclecount.c +4
-2@@ -468,7 +468,7 @@ cperf_cyclecount_test_runner(void *test_ctx)struct cperf_cyclecount_ctx *ctx = test_ctx;struct comp_test_data *test_data = ctx->ver.options;uint32_t lcore =rte_lcore_id (); -static rte_atomic16_t display_once =RTE_ATOMIC16_INIT (0 ); +static uint16_t display_once;static rte_spinlock_t print_spinlock;int i;@@ -488,10 +488,12 @@ cperf_cyclecount_test_runner(void *test_ctx) ctx->ver.mem.lcore_id = lcore; +uint16_t exp =0 ;/* * printing information about current compression thread */ -if (rte_atomic16_test_and_set (&ctx->ver.mem.print_info_once)) +if (__atomic_compare_exchange_n (&ctx->ver.mem.print_info_once, &exp, +1 ,0 , __ATOMIC_RELAXED, __ATOMIC_RELAXED)) printf(" lcore: %u,"app/test-compress-perf/comp_perf_test_cyclecount.c +0
-0" driver name: %s," " device name: %s,"
app/test-compress-perf/comp_perf_test_cyclecount.c cperf_cyclecount_test_runner(void *test_ctx) · line 555
Quoted 8 lines
app/test-compress-perf/comp_perf_test_cyclecount.c +3
-1@@ -547,8 +549,10 @@ cperf_cyclecount_test_runner(void *test_ctx) duration_setup_per_op = ctx->duration_op / (ctx->ver.mem.total_bufs * test_data->num_iter); + exp =0 ;/* R E P O R T processing */ -if (rte_atomic16_test_and_set (&display_once)) { +if (__atomic_compare_exchange_n (&display_once, &exp,1 ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) {
I think we can re-organize the current code which will avoid using atomic operations on 'display_once'. How about the following code?
rte_spinlock_lock(&print_spinlock);
if (display_once != 1) {
display_once = 1;
printf("\nLegend for the table\n".....
<all other printfs>
}printf....
printf....
printf....rte_spinlock_unlock(&print_spinlock);
Rest of the changes look fine.
Quoted 70 lines
app/test-compress-perf/comp_perf_test_cyclecount.c +0
-0rte_spinlock_lock (&print_spinlock);app/test- renamed from app/test-compress-perf/comp_perf_test_throughput.c +0
-0
compress-perf/comp_perf_test_throughput.c
index13922b658c..f587ad2ec3100644app/test-compress-perf/comp_perf_test_throughput.c +5
-2@@ -329,15 +329,18 @@ cperf_throughput_test_runner(void *test_ctx)struct cperf_benchmark_ctx *ctx = test_ctx;struct comp_test_data *test_data = ctx->ver.options;uint32_t lcore =rte_lcore_id (); -static rte_atomic16_t display_once =RTE_ATOMIC16_INIT (0 ); +static uint16_t display_once;int i, ret =EXIT_SUCCESS ; ctx->ver.mem.lcore_id = lcore; +uint16_t exp =0 ;/* * printing information about current compression thread */ -if (rte_atomic16_test_and_set (&ctx->ver.mem.print_info_once)) +if (__atomic_compare_exchange_n (&ctx->ver.mem.print_info_once, &exp, +1 ,0 , __ATOMIC_RELAXED, __ATOMIC_RELAXED)) + printf(" lcore: %u,"app/test-compress-perf/comp_perf_test_throughput.c +3
-1" driver name: %s," " device name: %s," @@ -391,7 +394,9 @@ cperf_throughput_test_runner(void *test_ctx) ctx->decomp_gbps =rte_get_tsc_hz () / ctx->decomp_tsc_byte *8 /1000000000 ; -if (rte_atomic16_test_and_set (&display_once)) { + exp =0 ; +if (__atomic_compare_exchange_n (&display_once, &exp,1 ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) {printf ("\n%12s%6s%12s%17s%15s%16s\n" ,"lcore id" ,"Level" ,"Comp size" ,"Comp ratio [%]" ,"Comp [Gbps]" ,"Decomp [Gbps]" );app/test- renamed from app/test-compress-perf/comp_perf_test_verify.c +0
-0
compress-perf/comp_perf_test_verify.c
index5e13257b79..6a2497985b100644app/test-compress-perf/comp_perf_test_verify.c +4
-2@@ -388,7 +388,7 @@ cperf_verify_test_runner(void *test_ctx)struct cperf_verify_ctx *ctx = test_ctx;struct comp_test_data *test_data = ctx->options;int ret =EXIT_SUCCESS ; -static rte_atomic16_t display_once =RTE_ATOMIC16_INIT (0 ); +static uint16_t display_once;uint32_t lcore =rte_lcore_id (); ctx->mem.lcore_id = lcore;@@ -428,7 +428,9 @@ cperf_verify_test_runner(void *test_ctx) test_data->input_data_sz *100 ;if (!ctx->silent) { -if (rte_atomic16_test_and_set (&display_once)) { +uint16_t exp =0 ; +if (__atomic_compare_exchange_n (&display_once, &exp,1 ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) {printf ("%12s%6s%12s%17s\n" ,"lcore id" ,"Level" ,"Comp size" ,"Comp ratio [%]" );}
--
2.17.1
RE: [PATCH v1 09/12] app/compress: use compiler atomic builtins for display sync
Quoted 17 lines
<snip>
app/test-compress-perf/comp_perf_test_cyclecount.c cperf_cyclecount_test_runner(void *test_ctx) · line 555
Quoted 6 lines
app/test-compress-perf/comp_perf_test_cyclecount.c +3
-1+ exp =0 ;/* R E P O R T processing */ -if (rte_atomic16_test_and_set (&display_once)) { +if (__atomic_compare_exchange_n (&display_once, &exp,1 ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) {I think we can re-organize the current code which will avoid using atomic operations on '
display_once'. How about the following code?
rte_spinlock_lock(&print_spinlock);if (display_once != 1) { display_once = 1; printf("\nLegend for the table\n"..... <all other printfs> }
Quoted 7 lines
printf....
printf....
printf....rte_spinlock_unlock(&print_spinlock);Rest of the changes look fine.
Will send out the next version with the changes.
PATCH 10/12 app/testpmd: use compiler atomic builtins for port sync
In reply to Joyce KongReplace rte_atomic16_cmpset operation with compiler atomic CAS operation for port status sync in testpmd case.
--- app/test-pmd/testpmd.c | 75 +++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 27 deletions(-)
app/test-pmd/testpmd.c +48 -27
@@ -36,7 +36,6 @@#include <rte_alarm.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_mempool.h> #include <rte_malloc.h>
@@ -2302,6 +2301,7 @@ setup_hairpin_queues(portid_t pi, portid_t p_pi, uint16_t cnt_pi)uint16_t peer_tx_port = pi;uint32_t manual =1 ;uint32_t tx_exp = hairpin_mode &0x10 ; +uint16_t port_exp;if (!(hairpin_mode &0xf )) { peer_rx_port = pi;
@@ -2347,10 +2347,11 @@ setup_hairpin_queues(portid_t pi, portid_t p_pi, uint16_t cnt_pi)if (diag ==0 )continue ; + port_exp =RTE_PORT_HANDLING ;/* Fail to setup rx queue, return */ -if (rte_atomic16_cmpset (&(port->port_status), -RTE_PORT_HANDLING , -RTE_PORT_STOPPED ) ==0 ) +if (__atomic_compare_exchange_n (&(port->port_status), + &port_exp,RTE_PORT_STOPPED ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED) ==0 )fprintf (stderr,"Port %d can not be set back to stopped\n" , pi); fprintf(stderr, "Fail to configure port %d hairpin queues\n",
@@ -2370,10 +2371,11 @@ setup_hairpin_queues(portid_t pi, portid_t p_pi, uint16_t cnt_pi)if (diag ==0 )continue ; + port_exp =RTE_PORT_HANDLING ;/* Fail to setup rx queue, return */ -if (rte_atomic16_cmpset (&(port->port_status), -RTE_PORT_HANDLING , -RTE_PORT_STOPPED ) ==0 ) +if (__atomic_compare_exchange_n (&(port->port_status), + &port_exp,RTE_PORT_STOPPED ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED) ==0 )fprintf (stderr,"Port %d can not be set back to stopped\n" , pi); fprintf(stderr, "Fail to configure port %d hairpin queues\n",
@@ -2444,6 +2446,7 @@ start_port(portid_t pid)queueid_t qi;struct rte_port *port;struct rte_eth_hairpin_cap cap; +uint16_t port_exp;if (port_id_is_invalid (pid,ENABLED_WARN ))return 0 ;
@@ -2454,8 +2457,10 @@ start_port(portid_t pid) need_check_link_status =0 ; port = &ports[pi]; -if (rte_atomic16_cmpset (&(port->port_status),RTE_PORT_STOPPED , -RTE_PORT_HANDLING ) ==0 ) { + port_exp =RTE_PORT_STOPPED ; +if (__atomic_compare_exchange_n (&(port->port_status), + &port_exp,RTE_PORT_HANDLING ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED) ==0 ) {fprintf (stderr,"Port %d is now not stopped\n" , pi);continue ; }
@@ -2487,8 +2492,10 @@ start_port(portid_t pid) nb_txq + nb_hairpinq, &(port->dev_conf));if (diag !=0 ) { -if (rte_atomic16_cmpset (&(port->port_status), -RTE_PORT_HANDLING ,RTE_PORT_STOPPED ) ==0 ) + port_exp =RTE_PORT_HANDLING ; +if (__atomic_compare_exchange_n (&(port->port_status), + &port_exp,RTE_PORT_STOPPED ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED) ==0 )fprintf (stderr,"Port %d can not be set back to stopped\n" , pi);
@@ -2518,10 +2525,11 @@ start_port(portid_t pid)if (diag ==0 )continue ; + port_exp =RTE_PORT_HANDLING ;/* Fail to setup tx queue, return */ -if (rte_atomic16_cmpset (&(port->port_status), -RTE_PORT_HANDLING , -RTE_PORT_STOPPED ) ==0 ) +if (__atomic_compare_exchange_n (&(port->port_status), + &port_exp,RTE_PORT_STOPPED ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED) ==0 )fprintf (stderr,"Port %d can not be set back to stopped\n" , pi);
@@ -2570,10 +2578,11 @@ start_port(portid_t pid)if (diag ==0 )continue ; + port_exp =RTE_PORT_HANDLING ;/* Fail to setup rx queue, return */ -if (rte_atomic16_cmpset (&(port->port_status), -RTE_PORT_HANDLING , -RTE_PORT_STOPPED ) ==0 ) +if (__atomic_compare_exchange_n (&(port->port_status), + &port_exp,RTE_PORT_STOPPED ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED) ==0 )fprintf (stderr,"Port %d can not be set back to stopped\n" , pi);
@@ -2607,17 +2616,21 @@ start_port(portid_t pid)fprintf (stderr,"Fail to start port %d: %s\n" , pi,rte_strerror (-diag)); + port_exp =RTE_PORT_HANDLING ;/* Fail to setup rx queue, return */ -if (rte_atomic16_cmpset (&(port->port_status), -RTE_PORT_HANDLING ,RTE_PORT_STOPPED ) ==0 ) +if (__atomic_compare_exchange_n (&(port->port_status), + &port_exp,RTE_PORT_STOPPED ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED) ==0 )fprintf (stderr,"Port %d can not be set back to stopped\n" , pi);continue ; } -if (rte_atomic16_cmpset (&(port->port_status), -RTE_PORT_HANDLING ,RTE_PORT_STARTED ) ==0 ) + port_exp =RTE_PORT_HANDLING ; +if (__atomic_compare_exchange_n (&(port->port_status), + &port_exp,RTE_PORT_STARTED ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED) ==0 )fprintf (stderr,"Port %d can not be set into started\n" , pi);
@@ -2697,6 +2710,7 @@ stop_port(portid_t pid)int need_check_link_status =0 ;portid_t peer_pl[RTE_MAX_ETHPORTS ];int peer_pi; +uint16_t port_exp;if (port_id_is_invalid (pid,ENABLED_WARN ))return ;
@@ -2722,8 +2736,10 @@ stop_port(portid_t pid) } port = &ports[pi]; -if (rte_atomic16_cmpset (&(port->port_status),RTE_PORT_STARTED , -RTE_PORT_HANDLING ) ==0 ) + port_exp =RTE_PORT_STARTED ; +if (__atomic_compare_exchange_n (&(port->port_status), + &port_exp,RTE_PORT_HANDLING ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED) ==0 )continue ;if (hairpin_mode &0xf ) {
@@ -2749,8 +2765,10 @@ stop_port(portid_t pid)RTE_LOG (ERR ,EAL ,"rte_eth_dev_stop failed for port %u\n" , pi); -if (rte_atomic16_cmpset (&(port->port_status), -RTE_PORT_HANDLING ,RTE_PORT_STOPPED ) ==0 ) + port_exp =RTE_PORT_HANDLING ; +if (__atomic_compare_exchange_n (&(port->port_status), + &port_exp,RTE_PORT_STOPPED ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED) ==0 )fprintf (stderr,"Port %d can not be set into stopped\n" , pi); need_check_link_status =1 ;
@@ -2788,6 +2806,7 @@ close_port(portid_t pid) {portid_t pi;struct rte_port *port; +uint16_t port_exp;if (port_id_is_invalid (pid,ENABLED_WARN ))return ;
@@ -2813,8 +2832,10 @@ close_port(portid_t pid) } port = &ports[pi]; -if (rte_atomic16_cmpset (&(port->port_status), -RTE_PORT_CLOSED ,RTE_PORT_CLOSED ) ==1 ) { + port_exp =RTE_PORT_CLOSED ; +if (__atomic_compare_exchange_n (&(port->port_status), + &port_exp,RTE_PORT_CLOSED ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) {fprintf (stderr,"Port %d is already closed\n" , pi);continue ; }
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v1 10/12] app/testpmd: use compiler atomic builtins for port sync
+ Ferruh
<snip>
Hi Joyce/Ferruh,
I do not think the port_status changes need to be handled atomically. The changes to port_status do not seem to be happening from multiple threads. It seems to be getting modified during initialization or through the test pmd prompt.
Do we really need atomic operations on port_status?
Quoted 246 lines
Replace
rte_atomic16_cmpsetoperation with compiler atomic CAS operation for port status sync in testpmd case.Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- app/test-pmd/testpmd.c | 75 +++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 27 deletions(-)app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0
-0
6cbe9ba3c8..22579dd438100644app/test-pmd/testpmd.c +1
-1@@ -36,7 +36,6 @@#include <rte_alarm.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_mempool.h> #include <rte_malloc.h> @@ -2302,6 +2301,7 @@ setup_hairpin_queues(portid_t pi, portid_t p_pi, uint16_t cnt_pi)uint16_t peer_tx_port = pi;uint32_t manual =1 ;uint32_t tx_exp = hairpin_mode &0x10 ; +uint16_t port_exp;if (!(hairpin_mode &0xf )) {app/test-pmd/testpmd.c +4
-3peer_rx_port = pi;@@ -2347,10 +2347,11 @@ setup_hairpin_queues(portid_t pi, portid_t p_pi, uint16_t cnt_pi)if (diag ==0 )continue ; + port_exp =RTE_PORT_HANDLING ;/* Fail to setup rx queue, return */ -if (rte_atomic16_cmpset (&(port->port_status), -RTE_PORT_HANDLING , -RTE_PORT_STOPPED ) ==0 ) +if (__atomic_compare_exchange_n (&(port->port_status), + &port_exp,RTE_PORT_STOPPED ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED) ==0 ) fprintf(stderr,"Port %d can not be set back to stopped\n",
pi);app/test-pmd/testpmd.c +4
-3fprintf(stderr, "Fail to configure port %d hairpin queues\n",@@ -2370,10 +2371,11 @@ setup_hairpin_queues(portid_t pi, portid_t p_pi, uint16_t cnt_pi)if (diag ==0 )continue ; + port_exp =RTE_PORT_HANDLING ;/* Fail to setup rx queue, return */ -if (rte_atomic16_cmpset (&(port->port_status), -RTE_PORT_HANDLING , -RTE_PORT_STOPPED ) ==0 ) +if (__atomic_compare_exchange_n (&(port->port_status), + &port_exp,RTE_PORT_STOPPED ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED) ==0 ) fprintf(stderr,"Port %d can not be set back to stopped\n",
pi);app/test-pmd/testpmd.c +5
-2fprintf(stderr, "Fail to configure port %d hairpin queues\n",@@ -2444,6 +2446,7 @@ start_port(portid_t pid)queueid_t qi;struct rte_port *port;struct rte_eth_hairpin_cap cap; +uint16_t port_exp;if (port_id_is_invalid (pid,ENABLED_WARN ))return 0 ;@@ -2454,8 +2457,10 @@ start_port(portid_t pid) need_check_link_status =0 ; port = &ports[pi]; -if (rte_atomic16_cmpset (&(port->port_status),RTE_PORT_STOPPED , -RTE_PORT_HANDLING ) ==0 ) { + port_exp =RTE_PORT_STOPPED ; +if (__atomic_compare_exchange_n (&(port->port_status), + &port_exp,RTE_PORT_HANDLING ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED) ==0 ) {app/test-pmd/testpmd.c +3
-2fprintf (stderr,"Port %d is now not stopped\n" , pi);continue ; }@@ -2487,8 +2492,10 @@ start_port(portid_t pid) nb_txq + nb_hairpinq, &(port->dev_conf));if (diag !=0 ) { -if (rte_atomic16_cmpset (&(port- >port_status), -RTE_PORT_HANDLING ,RTE_PORT_STOPPED ) == 0) + port_exp =RTE_PORT_HANDLING ; + if (__atomic_compare_exchange_n(&(port- >port_status), + &port_exp,
RTE_PORT_STOPPED, 0,app/test-pmd/testpmd.c +1
-0+ __ATOMIC_RELAXED,
__ATOMIC_RELAXED) == 0)app/test-pmd/testpmd.c +0
-0fprintf(stderr, "Port %d can not be set backto stopped\n",
app/test-pmd/testpmd.c +2
-3pi);@@ -2518,10 +2525,11 @@ start_port(portid_t pid)if (diag ==0 )continue ; + port_exp =RTE_PORT_HANDLING ;/* Fail to setup tx queue, return */ -if (rte_atomic16_cmpset (&(port- >port_status), - RTE_PORT_HANDLING, -RTE_PORT_STOPPED ) == 0) + if (__atomic_compare_exchange_n(&(port-Quoted 1 line
port_status),app/test-pmd/testpmd.c +1
-0+ &port_exp,
RTE_PORT_STOPPED, 0,app/test-pmd/testpmd.c +1
-0+ __ATOMIC_RELAXED,
__ATOMIC_RELAXED) == 0)app/test-pmd/testpmd.c +0
-0fprintf(stderr, "Port %d can not be set backto stopped\n",
app/test-pmd/testpmd.c +2
-3pi);@@ -2570,10 +2578,11 @@ start_port(portid_t pid)if (diag ==0 )continue ; + port_exp =RTE_PORT_HANDLING ;/* Fail to setup rx queue, return */ -if (rte_atomic16_cmpset (&(port- >port_status), - RTE_PORT_HANDLING, -RTE_PORT_STOPPED ) == 0) + if (__atomic_compare_exchange_n(&(port-Quoted 1 line
port_status),app/test-pmd/testpmd.c +1
-0+ &port_exp,
RTE_PORT_STOPPED, 0,app/test-pmd/testpmd.c +1
-0+ __ATOMIC_RELAXED,
__ATOMIC_RELAXED) == 0)app/test-pmd/testpmd.c +0
-0fprintf(stderr, "Port %d can not be set backto stopped\n",
app/test-pmd/testpmd.c +8
-4pi);@@ -2607,17 +2616,21 @@ start_port(portid_t pid)fprintf (stderr,"Fail to start port %d: %s\n" , pi,rte_strerror (-diag)); + port_exp =RTE_PORT_HANDLING ;/* Fail to setup rx queue, return */ -if (rte_atomic16_cmpset (&(port->port_status), -RTE_PORT_HANDLING ,RTE_PORT_STOPPED ) == 0) +if (__atomic_compare_exchange_n (&(port- >port_status), + &port_exp,RTE_PORT_STOPPED ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED) ==0 )fprintf (stderr,"Port %d can not be set back to stopped\n", pi);continue ; } -if (rte_atomic16_cmpset (&(port->port_status), -RTE_PORT_HANDLING ,RTE_PORT_STARTED ) ==0 ) + port_exp =RTE_PORT_HANDLING ; +if (__atomic_compare_exchange_n (&(port->port_status), + &port_exp,RTE_PORT_STARTED ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED)== 0)
app/test-pmd/testpmd.c +5
-2fprintf (stderr,"Port %d can not be set into started\n" , pi);@@ -2697,6 +2710,7 @@ stop_port(portid_t pid)int need_check_link_status =0 ;portid_t peer_pl[RTE_MAX_ETHPORTS ];int peer_pi; +uint16_t port_exp;if (port_id_is_invalid (pid,ENABLED_WARN ))return ;@@ -2722,8 +2736,10 @@ stop_port(portid_t pid) } port = &ports[pi]; -if (rte_atomic16_cmpset (&(port->port_status),RTE_PORT_STARTED , -RTE_PORT_HANDLING ) ==0 ) + port_exp =RTE_PORT_STARTED ; +if (__atomic_compare_exchange_n (&(port->port_status), + &port_exp,RTE_PORT_HANDLING ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED) ==0 )continue ;app/test-pmd/testpmd.c +4
-2if (hairpin_mode &0xf ) {@@ -2749,8 +2765,10 @@ stop_port(portid_t pid) RTE_LOG(ERR, EAL, "rte_eth_dev_stop failed for port %u\n", pi); -if (rte_atomic16_cmpset (&(port->port_status), -RTE_PORT_HANDLING ,RTE_PORT_STOPPED ) ==0 ) + port_exp =RTE_PORT_HANDLING ; +if (__atomic_compare_exchange_n (&(port->port_status), + &port_exp,RTE_PORT_STOPPED ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED) ==0 ) fprintf(stderr, "Port %d can not be set intostopped\n",
app/test-pmd/testpmd.c +5
-3pi); need_check_link_status =1 ;@@ -2788,6 +2806,7 @@ close_port(portid_t pid) {portid_t pi;struct rte_port *port; +uint16_t port_exp;if (port_id_is_invalid (pid,ENABLED_WARN ))return ;@@ -2813,8 +2832,10 @@ close_port(portid_t pid) } port = &ports[pi]; -if (rte_atomic16_cmpset (&(port->port_status), -RTE_PORT_CLOSED ,RTE_PORT_CLOSED ) ==1 ) { + port_exp =RTE_PORT_CLOSED ; +if (__atomic_compare_exchange_n (&(port->port_status), + &port_exp,RTE_PORT_CLOSED ,0 , + __ATOMIC_RELAXED, __ATOMIC_RELAXED)) {fprintf (stderr,"Port %d is already closed\n" , pi);continue ; } --2.17.1
RE: [PATCH v1 10/12] app/testpmd: use compiler atomic builtins for port sync
Quoted 4 lines
+ Ferruh
<snip>
Quoted 8 lines
Hi Joyce/Ferruh,
I do not think theport_statuschanges need to be handled atomically. The
changes toport_statusdo not seem to be happening from multiple threads. It seems to be getting modified during initialization or through the test pmd prompt.Do we really need atomic operations on
port_status?
Hi Honnappa,
Seem you are right, I shall remove the atomic operations for port_status. Joyce
Quoted 11 lines
Quoted 11 lines
Replace
rte_atomic16_cmpsetoperation with compiler atomic CAS operation for port status sync in testpmd case.Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- app/test-pmd/testpmd.c | 75 +++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 27 deletions(-)
PATCH 11/12 app/bbdev: use compiler atomics for thread sync
In reply to Joyce KongConvert rte_atomic usages to compiler atomic built-ins for thread params sync in bbdev cases.
--- app/test-bbdev/test_bbdev_perf.c | 135 ++++++++++++++----------------- 1 file changed, 59 insertions(+), 76 deletions(-)
app/test-bbdev/test_bbdev_perf.c +59 -76
@@ -133,7 +133,7 @@ struct test_op_params {uint16_t num_to_process;uint16_t num_lcores;int vector_mask; -rte_atomic16_t sync; +uint16_t sync;struct test_buffers q_bufs[RTE_MAX_NUMA_NODES ][MAX_QUEUES ]; };
@@ -148,9 +148,9 @@ struct thread_params {uint8_t iter_count;double iter_average;double bler; -rte_atomic16_t nb_dequeued; -rte_atomic16_t processing_status; -rte_atomic16_t burst_sz; +uint16_t nb_dequeued; +int16_t processing_status; +uint16_t burst_sz;struct test_op_params *op_params;struct rte_bbdev_dec_op *dec_ops[MAX_BURST ];struct rte_bbdev_enc_op *enc_ops[MAX_BURST ];
@@ -2594,46 +2594,46 @@ dequeue_event_callback(uint16_t dev_id, }if (unlikely (event !=RTE_BBDEV_EVENT_DEQUEUE )) { -rte_atomic16_set (&tp->processing_status,TEST_FAILED ); +__atomic_store_n (&tp->processing_status,TEST_FAILED , __ATOMIC_RELAXED);printf ("Dequeue interrupt handler called for incorrect event!\n" );return ; } - burst_sz =rte_atomic16_read (&tp->burst_sz); + burst_sz =__atomic_load_n (&tp->burst_sz, __ATOMIC_RELAXED); num_ops = tp->op_params->num_to_process;if (test_vector.op_type ==RTE_BBDEV_OP_TURBO_DEC ) deq =rte_bbdev_dequeue_dec_ops (dev_id, queue_id, &tp->dec_ops[ -rte_atomic16_read (&tp->nb_dequeued)], +__atomic_load_n (&tp->nb_dequeued, __ATOMIC_RELAXED)], burst_sz);else if (test_vector.op_type ==RTE_BBDEV_OP_LDPC_DEC ) deq =rte_bbdev_dequeue_ldpc_dec_ops (dev_id, queue_id, &tp->dec_ops[ -rte_atomic16_read (&tp->nb_dequeued)], +__atomic_load_n (&tp->nb_dequeued, __ATOMIC_RELAXED)], burst_sz);else if (test_vector.op_type ==RTE_BBDEV_OP_LDPC_ENC ) deq =rte_bbdev_dequeue_ldpc_enc_ops (dev_id, queue_id, &tp->enc_ops[ -rte_atomic16_read (&tp->nb_dequeued)], +__atomic_load_n (&tp->nb_dequeued, __ATOMIC_RELAXED)], burst_sz);else /*RTE_BBDEV_OP_TURBO_ENC*/ deq =rte_bbdev_dequeue_enc_ops (dev_id, queue_id, &tp->enc_ops[ -rte_atomic16_read (&tp->nb_dequeued)], +__atomic_load_n (&tp->nb_dequeued, __ATOMIC_RELAXED)], burst_sz);if (deq < burst_sz) {printf ("After receiving the interrupt all operations should be dequeued. Expected: %u, got: %u\n" , burst_sz, deq); -rte_atomic16_set (&tp->processing_status,TEST_FAILED ); +__atomic_store_n (&tp->processing_status,TEST_FAILED , __ATOMIC_RELAXED);return ; } -if (rte_atomic16_read (&tp->nb_dequeued) + deq < num_ops) { -rte_atomic16_add (&tp->nb_dequeued, deq); +if (__atomic_load_n (&tp->nb_dequeued, __ATOMIC_RELAXED) + deq < num_ops) { +__atomic_fetch_add (&tp->nb_dequeued, deq, __ATOMIC_RELAXED);return ; }
@@ -2670,7 +2670,7 @@ dequeue_event_callback(uint16_t dev_id,if (ret) {printf ("Buffers validation failed\n" ); -rte_atomic16_set (&tp->processing_status,TEST_FAILED ); +__atomic_store_n (&tp->processing_status,TEST_FAILED , __ATOMIC_RELAXED); }switch (test_vector.op_type) {
@@ -2691,7 +2691,7 @@ dequeue_event_callback(uint16_t dev_id,break ;default :printf ("Unknown op type: %d\n" , test_vector.op_type); -rte_atomic16_set (&tp->processing_status,TEST_FAILED ); +__atomic_store_n (&tp->processing_status,TEST_FAILED , __ATOMIC_RELAXED);return ; }
@@ -2700,7 +2700,7 @@ dequeue_event_callback(uint16_t dev_id, tp->mbps += (((double )(num_ops * tb_len_bits)) /1000000.0 ) / ((double )total_time / (double )rte_get_tsc_hz ()); -rte_atomic16_add (&tp->nb_dequeued, deq); +__atomic_fetch_add (&tp->nb_dequeued, deq, __ATOMIC_RELAXED); } static int
@@ -2738,11 +2738,10 @@ throughput_intr_lcore_ldpc_dec(void *arg) bufs = &tp->op_params->q_bufs[GET_SOCKET (info.socket_id)][queue_id]; -rte_atomic16_clear (&tp->processing_status); -rte_atomic16_clear (&tp->nb_dequeued); +__atomic_store_n (&tp->processing_status,0 , __ATOMIC_RELAXED); +__atomic_store_n (&tp->nb_dequeued,0 , __ATOMIC_RELAXED); -while (rte_atomic16_read (&tp->op_params->sync) ==SYNC_WAIT ) -rte_pause (); +rte_wait_until_equal_16 (&tp->op_params->sync,SYNC_START , __ATOMIC_RELAXED); ret =rte_bbdev_dec_op_alloc_bulk (tp->op_params->mp, ops, num_to_process);
@@ -2790,17 +2789,15 @@ throughput_intr_lcore_ldpc_dec(void *arg)* the number of operations is not a multiple of * burst size. */ -rte_atomic16_set (&tp->burst_sz, num_to_enq); +__atomic_store_n (&tp->burst_sz, num_to_enq, __ATOMIC_RELAXED);/* Wait until processing of previous batch is * completed */ -while (rte_atomic16_read (&tp->nb_dequeued) != - (int16_t ) enqueued) -rte_pause (); +rte_wait_until_equal_16 (&tp->nb_dequeued, enqueued, __ATOMIC_RELAXED); }if (j !=TEST_REPETITIONS -1 ) -rte_atomic16_clear (&tp->nb_dequeued); +__atomic_store_n (&tp->nb_dequeued,0 , __ATOMIC_RELAXED); }return TEST_SUCCESS ;
@@ -2835,11 +2832,10 @@ throughput_intr_lcore_dec(void *arg) bufs = &tp->op_params->q_bufs[GET_SOCKET (info.socket_id)][queue_id]; -rte_atomic16_clear (&tp->processing_status); -rte_atomic16_clear (&tp->nb_dequeued); +__atomic_store_n (&tp->processing_status,0 , __ATOMIC_RELAXED); +__atomic_store_n (&tp->nb_dequeued,0 , __ATOMIC_RELAXED); -while (rte_atomic16_read (&tp->op_params->sync) ==SYNC_WAIT ) -rte_pause (); +rte_wait_until_equal_16 (&tp->op_params->sync,SYNC_START , __ATOMIC_RELAXED); ret =rte_bbdev_dec_op_alloc_bulk (tp->op_params->mp, ops, num_to_process);
@@ -2880,17 +2876,15 @@ throughput_intr_lcore_dec(void *arg)* the number of operations is not a multiple of * burst size. */ -rte_atomic16_set (&tp->burst_sz, num_to_enq); +__atomic_store_n (&tp->burst_sz, num_to_enq, __ATOMIC_RELAXED);/* Wait until processing of previous batch is * completed */ -while (rte_atomic16_read (&tp->nb_dequeued) != - (int16_t ) enqueued) -rte_pause (); +rte_wait_until_equal_16 (&tp->nb_dequeued, enqueued, __ATOMIC_RELAXED); }if (j !=TEST_REPETITIONS -1 ) -rte_atomic16_clear (&tp->nb_dequeued); +__atomic_store_n (&tp->nb_dequeued,0 , __ATOMIC_RELAXED); }return TEST_SUCCESS ;
@@ -2925,11 +2919,10 @@ throughput_intr_lcore_enc(void *arg) bufs = &tp->op_params->q_bufs[GET_SOCKET (info.socket_id)][queue_id]; -rte_atomic16_clear (&tp->processing_status); -rte_atomic16_clear (&tp->nb_dequeued); +__atomic_store_n (&tp->processing_status,0 , __ATOMIC_RELAXED); +__atomic_store_n (&tp->nb_dequeued,0 , __ATOMIC_RELAXED); -while (rte_atomic16_read (&tp->op_params->sync) ==SYNC_WAIT ) -rte_pause (); +rte_wait_until_equal_16 (&tp->op_params->sync,SYNC_START , __ATOMIC_RELAXED); ret =rte_bbdev_enc_op_alloc_bulk (tp->op_params->mp, ops, num_to_process);
@@ -2969,17 +2962,15 @@ throughput_intr_lcore_enc(void *arg)* the number of operations is not a multiple of * burst size. */ -rte_atomic16_set (&tp->burst_sz, num_to_enq); +__atomic_store_n (&tp->burst_sz, num_to_enq, __ATOMIC_RELAXED);/* Wait until processing of previous batch is * completed */ -while (rte_atomic16_read (&tp->nb_dequeued) != - (int16_t ) enqueued) -rte_pause (); +rte_wait_until_equal_16 (&tp->nb_dequeued, enqueued, __ATOMIC_RELAXED); }if (j !=TEST_REPETITIONS -1 ) -rte_atomic16_clear (&tp->nb_dequeued); +__atomic_store_n (&tp->nb_dequeued,0 , __ATOMIC_RELAXED); }return TEST_SUCCESS ;
@@ -3015,11 +3006,10 @@ throughput_intr_lcore_ldpc_enc(void *arg) bufs = &tp->op_params->q_bufs[GET_SOCKET (info.socket_id)][queue_id]; -rte_atomic16_clear (&tp->processing_status); -rte_atomic16_clear (&tp->nb_dequeued); +__atomic_store_n (&tp->processing_status,0 , __ATOMIC_RELAXED); +__atomic_store_n (&tp->nb_dequeued,0 , __ATOMIC_RELAXED); -while (rte_atomic16_read (&tp->op_params->sync) ==SYNC_WAIT ) -rte_pause (); +rte_wait_until_equal_16 (&tp->op_params->sync,SYNC_START , __ATOMIC_RELAXED); ret =rte_bbdev_enc_op_alloc_bulk (tp->op_params->mp, ops, num_to_process);
@@ -3061,17 +3051,15 @@ throughput_intr_lcore_ldpc_enc(void *arg)* the number of operations is not a multiple of * burst size. */ -rte_atomic16_set (&tp->burst_sz, num_to_enq); +__atomic_store_n (&tp->burst_sz, num_to_enq, __ATOMIC_RELAXED);/* Wait until processing of previous batch is * completed */ -while (rte_atomic16_read (&tp->nb_dequeued) != - (int16_t ) enqueued) -rte_pause (); +rte_wait_until_equal_16 (&tp->nb_dequeued, enqueued, __ATOMIC_RELAXED); }if (j !=TEST_REPETITIONS -1 ) -rte_atomic16_clear (&tp->nb_dequeued); +__atomic_store_n (&tp->nb_dequeued,0 , __ATOMIC_RELAXED); }return TEST_SUCCESS ;
@@ -3105,8 +3093,7 @@ throughput_pmd_lcore_dec(void *arg) bufs = &tp->op_params->q_bufs[GET_SOCKET (info.socket_id)][queue_id]; -while (rte_atomic16_read (&tp->op_params->sync) ==SYNC_WAIT ) -rte_pause (); +rte_wait_until_equal_16 (&tp->op_params->sync,SYNC_START , __ATOMIC_RELAXED); ret =rte_bbdev_dec_op_alloc_bulk (tp->op_params->mp, ops_enq, num_ops);TEST_ASSERT_SUCCESS (ret,"Allocation failed for %d ops" , num_ops);
@@ -3209,8 +3196,7 @@ bler_pmd_lcore_ldpc_dec(void *arg) bufs = &tp->op_params->q_bufs[GET_SOCKET (info.socket_id)][queue_id]; -while (rte_atomic16_read (&tp->op_params->sync) ==SYNC_WAIT ) -rte_pause (); +rte_wait_until_equal_16 (&tp->op_params->sync,SYNC_START , __ATOMIC_RELAXED); ret =rte_bbdev_dec_op_alloc_bulk (tp->op_params->mp, ops_enq, num_ops);TEST_ASSERT_SUCCESS (ret,"Allocation failed for %d ops" , num_ops);
@@ -3339,8 +3325,7 @@ throughput_pmd_lcore_ldpc_dec(void *arg) bufs = &tp->op_params->q_bufs[GET_SOCKET (info.socket_id)][queue_id]; -while (rte_atomic16_read (&tp->op_params->sync) ==SYNC_WAIT ) -rte_pause (); +rte_wait_until_equal_16 (&tp->op_params->sync,SYNC_START , __ATOMIC_RELAXED); ret =rte_bbdev_dec_op_alloc_bulk (tp->op_params->mp, ops_enq, num_ops);TEST_ASSERT_SUCCESS (ret,"Allocation failed for %d ops" , num_ops);
@@ -3456,8 +3441,7 @@ throughput_pmd_lcore_enc(void *arg) bufs = &tp->op_params->q_bufs[GET_SOCKET (info.socket_id)][queue_id]; -while (rte_atomic16_read (&tp->op_params->sync) ==SYNC_WAIT ) -rte_pause (); +rte_wait_until_equal_16 (&tp->op_params->sync,SYNC_START , __ATOMIC_RELAXED); ret =rte_bbdev_enc_op_alloc_bulk (tp->op_params->mp, ops_enq, num_ops);
@@ -3547,8 +3531,7 @@ throughput_pmd_lcore_ldpc_enc(void *arg) bufs = &tp->op_params->q_bufs[GET_SOCKET (info.socket_id)][queue_id]; -while (rte_atomic16_read (&tp->op_params->sync) ==SYNC_WAIT ) -rte_pause (); +rte_wait_until_equal_16 (&tp->op_params->sync,SYNC_START , __ATOMIC_RELAXED); ret =rte_bbdev_enc_op_alloc_bulk (tp->op_params->mp, ops_enq, num_ops);
@@ -3731,7 +3714,7 @@ bler_test(struct active_device *ad,else return TEST_SKIPPED ; -rte_atomic16_set (&op_params->sync,SYNC_WAIT ); +__atomic_store_n (&op_params->sync,SYNC_WAIT , __ATOMIC_RELAXED);/* Main core is set at first entry */ t_params[0 ].dev_id = ad->dev_id;
@@ -3754,7 +3737,7 @@ bler_test(struct active_device *ad, &t_params[used_cores++], lcore_id); } -rte_atomic16_set (&op_params->sync,SYNC_START ); +__atomic_store_n (&op_params->sync,SYNC_START , __ATOMIC_RELAXED); ret =bler_function (&t_params[0 ]);/* Main core is always used */
@@ -3849,7 +3832,7 @@ throughput_test(struct active_device *ad, throughput_function = throughput_pmd_lcore_enc; } -rte_atomic16_set (&op_params->sync,SYNC_WAIT ); +__atomic_store_n (&op_params->sync,SYNC_WAIT , __ATOMIC_RELAXED);/* Main core is set at first entry */ t_params[0 ].dev_id = ad->dev_id;
@@ -3872,7 +3855,7 @@ throughput_test(struct active_device *ad, &t_params[used_cores++], lcore_id); } -rte_atomic16_set (&op_params->sync,SYNC_START ); +__atomic_store_n (&op_params->sync,SYNC_START , __ATOMIC_RELAXED); ret =throughput_function (&t_params[0 ]);/* Main core is always used */
@@ -3902,29 +3885,29 @@ throughput_test(struct active_device *ad,* Wait for main lcore operations. */ tp = &t_params[0 ]; -while ((rte_atomic16_read (&tp->nb_dequeued) < - op_params->num_to_process) && - (rte_atomic16_read (&tp->processing_status) != -TEST_FAILED )) +while ((__atomic_load_n (&tp->nb_dequeued, __ATOMIC_RELAXED) < + op_params->num_to_process) && + (__atomic_load_n (&tp->processing_status, __ATOMIC_RELAXED) != +TEST_FAILED ))rte_pause (); tp->ops_per_sec /=TEST_REPETITIONS ; tp->mbps /=TEST_REPETITIONS ; - ret |= (int )rte_atomic16_read (&tp->processing_status); + ret |= (int )__atomic_load_n (&tp->processing_status, __ATOMIC_RELAXED);/* Wait for worker lcores operations */ for (used_cores =1 ; used_cores < num_lcores; used_cores++) { tp = &t_params[used_cores]; -while ((rte_atomic16_read (&tp->nb_dequeued) < - op_params->num_to_process) && - (rte_atomic16_read (&tp->processing_status) != -TEST_FAILED )) +while ((__atomic_load_n (&tp->nb_dequeued, __ATOMIC_RELAXED) < + op_params->num_to_process) && + (__atomic_load_n (&tp->processing_status, __ATOMIC_RELAXED) != +TEST_FAILED ))rte_pause (); tp->ops_per_sec /=TEST_REPETITIONS ; tp->mbps /=TEST_REPETITIONS ; - ret |= (int )rte_atomic16_read (&tp->processing_status); + ret |= (int )__atomic_load_n (&tp->processing_status, __ATOMIC_RELAXED); }/* Print throughput if test passed */
Signature · 1 line
2.17.1
RE: [PATCH v1 11/12] app/bbdev: use compiler atomics for thread sync
<snip>
Quoted 1 line
Subject: [PATCH v1 11/12] app/bbdev: use compiler atomics for thread sync
There are multiple fields which are getting synchronized. How about the following:
app/bbdev: use compiler atomics for synchronizing shared data
Quoted 6 lines
Convert
rte_atomicusages to compiler atomic built-ins for thread params sync in bbdev cases.Signed-off-by Joyce Kong <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>
Otherwise, looks good
Quoted 449 lines
--- app/test-bbdev/test_bbdev_perf.c | 135 ++++++++++++++----------------- 1 file changed, 59 insertions(+), 76 deletions(-)app/test- renamed from app/test-bbdev/test_bbdev_perf.c +0
-0
bbdev/test_bbdev_perf.c
index469597b8b3..dc62e16216100644app/test-bbdev/test_bbdev_perf.c +7
-5@@ -133,7 +133,7 @@ struct test_op_params {uint16_t num_to_process;uint16_t num_lcores;int vector_mask; -rte_atomic16_t sync; +uint16_t sync;struct test_buffers q_bufs[RTE_MAX_NUMA_NODES ][MAX_QUEUES ]; };@@ -148,9 +148,9 @@ struct thread_params {uint8_t iter_count;double iter_average;double bler; -rte_atomic16_t nb_dequeued; -rte_atomic16_t processing_status; -rte_atomic16_t burst_sz; +uint16_t nb_dequeued; +int16_t processing_status; +uint16_t burst_sz;struct test_op_params *op_params;struct rte_bbdev_dec_op *dec_ops[MAX_BURST ]; struct rte_bbdev_enc_op *enc_ops[MAX_BURST]; @@ -2594,46 +2594,46 @@ dequeue_event_callback(uint16_t dev_id, }if (unlikely (event !=RTE_BBDEV_EVENT_DEQUEUE )) { -rte_atomic16_set (&tp->processing_status,TEST_FAILED ); +__atomic_store_n (&tp->processing_status,TEST_FAILED , +__ATOMIC_RELAXED); printf( "Dequeue interrupt handler called for incorrectevent!\n");
app/test-bbdev/test_bbdev_perf.c +1
-2return ; } - burst_sz =rte_atomic16_read (&tp->burst_sz); + burst_sz =__atomic_load_n (&tp->burst_sz, __ATOMIC_RELAXED); num_ops = tp->op_params->num_to_process;if (test_vector.op_type ==RTE_BBDEV_OP_TURBO_DEC ) deq =rte_bbdev_dequeue_dec_ops (dev_id, queue_id, &tp->dec_ops[ - rte_atomic16_read(&tp-Quoted 1 line
nb_dequeued)],app/test-bbdev/test_bbdev_perf.c +1
-0+ __atomic_load_n(&tp->nb_dequeued,
__ATOMIC_RELAXED)],app/test-bbdev/test_bbdev_perf.c +0
-1burst_sz); else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC) deq =rte_bbdev_dequeue_ldpc_dec_ops (dev_id, queue_id, &tp->dec_ops[ - rte_atomic16_read(&tp-Quoted 1 line
nb_dequeued)],app/test-bbdev/test_bbdev_perf.c +1
-0+ __atomic_load_n(&tp->nb_dequeued,
__ATOMIC_RELAXED)],app/test-bbdev/test_bbdev_perf.c +0
-1burst_sz); else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_ENC) deq =rte_bbdev_dequeue_ldpc_enc_ops (dev_id, queue_id, &tp->enc_ops[ - rte_atomic16_read(&tp-Quoted 1 line
nb_dequeued)],app/test-bbdev/test_bbdev_perf.c +1
-0+ __atomic_load_n(&tp->nb_dequeued,
__ATOMIC_RELAXED)],app/test-bbdev/test_bbdev_perf.c +0
-1burst_sz); else /*RTE_BBDEV_OP_TURBO_ENC*/ deq =rte_bbdev_dequeue_enc_ops (dev_id, queue_id, &tp->enc_ops[ - rte_atomic16_read(&tp-Quoted 1 line
nb_dequeued)],app/test-bbdev/test_bbdev_perf.c +1
-0+ __atomic_load_n(&tp->nb_dequeued,
__ATOMIC_RELAXED)],app/test-bbdev/test_bbdev_perf.c +0
-0burst_sz);if (deq < burst_sz) { printf( "After receiving the interrupt all operations should bedequeued. Expected: %u, got: %u\n",
app/test-bbdev/test_bbdev_perf.c +3
-3burst_sz, deq); -rte_atomic16_set (&tp->processing_status,TEST_FAILED ); +__atomic_store_n (&tp->processing_status,TEST_FAILED , +__ATOMIC_RELAXED);return ; } -if (rte_atomic16_read (&tp->nb_dequeued) + deq < num_ops) { -rte_atomic16_add (&tp->nb_dequeued, deq); + if (__atomic_load_n(&tp->nb_dequeued, __ATOMIC_RELAXED) + deq<
num_ops) {app/test-bbdev/test_bbdev_perf.c +1
-0+ __atomic_fetch_add(&tp->nb_dequeued, deq,
__ATOMIC_RELAXED);app/test-bbdev/test_bbdev_perf.c +13
-12return ; }@@ -2670,7 +2670,7 @@ dequeue_event_callback(uint16_t dev_id,if (ret) {printf ("Buffers validation failed\n" ); -rte_atomic16_set (&tp->processing_status,TEST_FAILED ); +__atomic_store_n (&tp->processing_status,TEST_FAILED , +__ATOMIC_RELAXED); }switch (test_vector.op_type) {@@ -2691,7 +2691,7 @@ dequeue_event_callback(uint16_t dev_id,break ;default :printf ("Unknown op type: %d\n" , test_vector.op_type); -rte_atomic16_set (&tp->processing_status,TEST_FAILED ); +__atomic_store_n (&tp->processing_status,TEST_FAILED , +__ATOMIC_RELAXED);return ; }@@ -2700,7 +2700,7 @@ dequeue_event_callback(uint16_t dev_id, tp->mbps += (((double )(num_ops * tb_len_bits)) /1000000.0 ) / ((double )total_time / (double )rte_get_tsc_hz ()); -rte_atomic16_add (&tp->nb_dequeued, deq); +__atomic_fetch_add (&tp->nb_dequeued, deq, __ATOMIC_RELAXED); } static int@@ -2738,11 +2738,10 @@ throughput_intr_lcore_ldpc_dec(void *arg) bufs = &tp->op_params- >q_bufs[GET_SOCKET(info.socket_id)][queue_id]; -rte_atomic16_clear (&tp->processing_status); -rte_atomic16_clear (&tp->nb_dequeued); +__atomic_store_n (&tp->processing_status,0 , __ATOMIC_RELAXED); +__atomic_store_n (&tp->nb_dequeued,0 , __ATOMIC_RELAXED); -while (rte_atomic16_read (&tp->op_params->sync) ==SYNC_WAIT ) -rte_pause (); +rte_wait_until_equal_16 (&tp->op_params->sync,SYNC_START , +__ATOMIC_RELAXED); ret =rte_bbdev_dec_op_alloc_bulk (tp->op_params->mp, ops, num_to_process);@@ -2790,17 +2789,15 @@ throughput_intr_lcore_ldpc_dec(void *arg)* the number of operations is not a multiple of * burst size. */ -rte_atomic16_set (&tp->burst_sz, num_to_enq); +__atomic_store_n (&tp->burst_sz, num_to_enq, __ATOMIC_RELAXED);/* Wait until processing of previous batch is * completed */ -while (rte_atomic16_read (&tp->nb_dequeued) != - (int16_t ) enqueued) -rte_pause (); +rte_wait_until_equal_16 (&tp->nb_dequeued, enqueued, +__ATOMIC_RELAXED); }if (j !=TEST_REPETITIONS -1 ) -rte_atomic16_clear (&tp->nb_dequeued); + __atomic_store_n(&tp->nb_dequeued, 0,
__ATOMIC_RELAXED);app/test-bbdev/test_bbdev_perf.c +8
-9}return TEST_SUCCESS ;@@ -2835,11 +2832,10 @@ throughput_intr_lcore_dec(void *arg) bufs = &tp->op_params- >q_bufs[GET_SOCKET(info.socket_id)][queue_id]; -rte_atomic16_clear (&tp->processing_status); -rte_atomic16_clear (&tp->nb_dequeued); +__atomic_store_n (&tp->processing_status,0 , __ATOMIC_RELAXED); +__atomic_store_n (&tp->nb_dequeued,0 , __ATOMIC_RELAXED); -while (rte_atomic16_read (&tp->op_params->sync) ==SYNC_WAIT ) -rte_pause (); +rte_wait_until_equal_16 (&tp->op_params->sync,SYNC_START , +__ATOMIC_RELAXED); ret =rte_bbdev_dec_op_alloc_bulk (tp->op_params->mp, ops, num_to_process);@@ -2880,17 +2876,15 @@ throughput_intr_lcore_dec(void *arg)* the number of operations is not a multiple of * burst size. */ -rte_atomic16_set (&tp->burst_sz, num_to_enq); +__atomic_store_n (&tp->burst_sz, num_to_enq, __ATOMIC_RELAXED);/* Wait until processing of previous batch is * completed */ -while (rte_atomic16_read (&tp->nb_dequeued) != - (int16_t ) enqueued) -rte_pause (); +rte_wait_until_equal_16 (&tp->nb_dequeued, enqueued, +__ATOMIC_RELAXED); }if (j !=TEST_REPETITIONS -1 ) -rte_atomic16_clear (&tp->nb_dequeued); + __atomic_store_n(&tp->nb_dequeued, 0,
__ATOMIC_RELAXED);app/test-bbdev/test_bbdev_perf.c +8
-9}return TEST_SUCCESS ;@@ -2925,11 +2919,10 @@ throughput_intr_lcore_enc(void *arg) bufs = &tp->op_params- >q_bufs[GET_SOCKET(info.socket_id)][queue_id]; -rte_atomic16_clear (&tp->processing_status); -rte_atomic16_clear (&tp->nb_dequeued); +__atomic_store_n (&tp->processing_status,0 , __ATOMIC_RELAXED); +__atomic_store_n (&tp->nb_dequeued,0 , __ATOMIC_RELAXED); -while (rte_atomic16_read (&tp->op_params->sync) ==SYNC_WAIT ) -rte_pause (); +rte_wait_until_equal_16 (&tp->op_params->sync,SYNC_START , +__ATOMIC_RELAXED); ret =rte_bbdev_enc_op_alloc_bulk (tp->op_params->mp, ops, num_to_process);@@ -2969,17 +2962,15 @@ throughput_intr_lcore_enc(void *arg)* the number of operations is not a multiple of * burst size. */ -rte_atomic16_set (&tp->burst_sz, num_to_enq); +__atomic_store_n (&tp->burst_sz, num_to_enq, __ATOMIC_RELAXED);/* Wait until processing of previous batch is * completed */ -while (rte_atomic16_read (&tp->nb_dequeued) != - (int16_t ) enqueued) -rte_pause (); +rte_wait_until_equal_16 (&tp->nb_dequeued, enqueued, +__ATOMIC_RELAXED); }if (j !=TEST_REPETITIONS -1 ) -rte_atomic16_clear (&tp->nb_dequeued); + __atomic_store_n(&tp->nb_dequeued, 0,
__ATOMIC_RELAXED);app/test-bbdev/test_bbdev_perf.c +8
-9}return TEST_SUCCESS ;@@ -3015,11 +3006,10 @@ throughput_intr_lcore_ldpc_enc(void *arg) bufs = &tp->op_params- >q_bufs[GET_SOCKET(info.socket_id)][queue_id]; -rte_atomic16_clear (&tp->processing_status); -rte_atomic16_clear (&tp->nb_dequeued); +__atomic_store_n (&tp->processing_status,0 , __ATOMIC_RELAXED); +__atomic_store_n (&tp->nb_dequeued,0 , __ATOMIC_RELAXED); -while (rte_atomic16_read (&tp->op_params->sync) ==SYNC_WAIT ) -rte_pause (); +rte_wait_until_equal_16 (&tp->op_params->sync,SYNC_START , +__ATOMIC_RELAXED); ret =rte_bbdev_enc_op_alloc_bulk (tp->op_params->mp, ops, num_to_process);@@ -3061,17 +3051,15 @@ throughput_intr_lcore_ldpc_enc(void *arg)* the number of operations is not a multiple of * burst size. */ -rte_atomic16_set (&tp->burst_sz, num_to_enq); +__atomic_store_n (&tp->burst_sz, num_to_enq, __ATOMIC_RELAXED);/* Wait until processing of previous batch is * completed */ -while (rte_atomic16_read (&tp->nb_dequeued) != - (int16_t ) enqueued) -rte_pause (); +rte_wait_until_equal_16 (&tp->nb_dequeued, enqueued, +__ATOMIC_RELAXED); }if (j !=TEST_REPETITIONS -1 ) -rte_atomic16_clear (&tp->nb_dequeued); + __atomic_store_n(&tp->nb_dequeued, 0,
__ATOMIC_RELAXED);app/test-bbdev/test_bbdev_perf.c +2
-2}return TEST_SUCCESS ;@@ -3105,8 +3093,7 @@ throughput_pmd_lcore_dec(void *arg) bufs = &tp->op_params- >q_bufs[GET_SOCKET(info.socket_id)][queue_id]; -while (rte_atomic16_read (&tp->op_params->sync) ==SYNC_WAIT ) -rte_pause (); +rte_wait_until_equal_16 (&tp->op_params->sync,SYNC_START , +__ATOMIC_RELAXED); ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops_enq,
num_ops);app/test-bbdev/test_bbdev_perf.c +2
-2TEST_ASSERT_SUCCESS (ret,"Allocation failed for %d ops" , num_ops);@@ -3209,8 +3196,7 @@ bler_pmd_lcore_ldpc_dec(void *arg) bufs = &tp->op_params- >q_bufs[GET_SOCKET(info.socket_id)][queue_id]; -while (rte_atomic16_read (&tp->op_params->sync) ==SYNC_WAIT ) -rte_pause (); +rte_wait_until_equal_16 (&tp->op_params->sync,SYNC_START , +__ATOMIC_RELAXED); ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops_enq,
num_ops);app/test-bbdev/test_bbdev_perf.c +2
-2TEST_ASSERT_SUCCESS (ret,"Allocation failed for %d ops" , num_ops);@@ -3339,8 +3325,7 @@ throughput_pmd_lcore_ldpc_dec(void *arg) bufs = &tp->op_params- >q_bufs[GET_SOCKET(info.socket_id)][queue_id]; -while (rte_atomic16_read (&tp->op_params->sync) ==SYNC_WAIT ) -rte_pause (); +rte_wait_until_equal_16 (&tp->op_params->sync,SYNC_START , +__ATOMIC_RELAXED); ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops_enq,
num_ops);app/test-bbdev/test_bbdev_perf.c +5
-5TEST_ASSERT_SUCCESS (ret,"Allocation failed for %d ops" , num_ops);@@ -3456,8 +3441,7 @@ throughput_pmd_lcore_enc(void *arg) bufs = &tp->op_params- >q_bufs[GET_SOCKET(info.socket_id)][queue_id]; -while (rte_atomic16_read (&tp->op_params->sync) ==SYNC_WAIT ) -rte_pause (); +rte_wait_until_equal_16 (&tp->op_params->sync,SYNC_START , +__ATOMIC_RELAXED); ret =rte_bbdev_enc_op_alloc_bulk (tp->op_params->mp, ops_enq, num_ops);@@ -3547,8 +3531,7 @@ throughput_pmd_lcore_ldpc_enc(void *arg) bufs = &tp->op_params- >q_bufs[GET_SOCKET(info.socket_id)][queue_id]; -while (rte_atomic16_read (&tp->op_params->sync) ==SYNC_WAIT ) -rte_pause (); +rte_wait_until_equal_16 (&tp->op_params->sync,SYNC_START , +__ATOMIC_RELAXED); ret =rte_bbdev_enc_op_alloc_bulk (tp->op_params->mp, ops_enq, num_ops);@@ -3731,7 +3714,7 @@ bler_test(struct active_device *ad,else return TEST_SKIPPED ; -rte_atomic16_set (&op_params->sync,SYNC_WAIT ); +__atomic_store_n (&op_params->sync,SYNC_WAIT , __ATOMIC_RELAXED);/* Main core is set at first entry */ app/test-bbdev/test_bbdev_perf.c +1
-1t_params[0 ].dev_id = ad->dev_id;@@ -3754,7 +3737,7 @@ bler_test(struct active_device *ad, &t_params[used_cores++], lcore_id); } -rte_atomic16_set (&op_params->sync,SYNC_START ); +__atomic_store_n (&op_params->sync,SYNC_START , __ATOMIC_RELAXED); ret =bler_function (&t_params[0 ]);app/test-bbdev/test_bbdev_perf.c +1
-1/* Main core is always used */ @@ -3849,7 +3832,7 @@ throughput_test(struct active_device *ad, throughput_function = throughput_pmd_lcore_enc; } -rte_atomic16_set (&op_params->sync,SYNC_WAIT ); +__atomic_store_n (&op_params->sync,SYNC_WAIT , __ATOMIC_RELAXED);/* Main core is set at first entry */ app/test-bbdev/test_bbdev_perf.c +1
-1t_params[0 ].dev_id = ad->dev_id;@@ -3872,7 +3855,7 @@ throughput_test(struct active_device *ad, &t_params[used_cores++], lcore_id); } -rte_atomic16_set (&op_params->sync,SYNC_START ); +__atomic_store_n (&op_params->sync,SYNC_START , __ATOMIC_RELAXED); ret =throughput_function (&t_params[0 ]);app/test-bbdev/test_bbdev_perf.c +3
-4/* Main core is always used */ @@ -3902,29 +3885,29 @@ throughput_test(struct active_device *ad,* Wait for main lcore operations. */ tp = &t_params[0 ]; -while ((rte_atomic16_read (&tp->nb_dequeued) < - op_params->num_to_process) && - (rte_atomic16_read (&tp->processing_status) != -TEST_FAILED )) + while ((__atomic_load_n(&tp->nb_dequeued, __ATOMIC_RELAXED) < + op_params->num_to_process) && + (__atomic_load_n(&tp->processing_status,
__ATOMIC_RELAXED) !=app/test-bbdev/test_bbdev_perf.c +2
-1+ TEST_FAILED))rte_pause (); tp->ops_per_sec /=TEST_REPETITIONS ; tp->mbps /=TEST_REPETITIONS ; - ret |= (int )rte_atomic16_read (&tp->processing_status); + ret |= (int)__atomic_load_n(&tp->processing_status,
__ATOMIC_RELAXED);app/test-bbdev/test_bbdev_perf.c +0
-3/* Wait for worker lcores operations */ for (used_cores =1 ; used_cores < num_lcores; used_cores++) { tp = &t_params[used_cores]; - while ((rte_atomic16_read(&tp->nb_dequeued) < - op_params->num_to_process) && - (rte_atomic16_read(&tp->processing_status)!=
app/test-bbdev/test_bbdev_perf.c +1
-1- TEST_FAILED)) + while ((__atomic_load_n(&tp->nb_dequeued,
__ATOMIC_RELAXED) <app/test-bbdev/test_bbdev_perf.c +2
-0+ op_params->num_to_process) && + (__atomic_load_n(&tp->processing_status,
__ATOMIC_RELAXED) !=app/test-bbdev/test_bbdev_perf.c +3
-2+ TEST_FAILED))rte_pause (); tp->ops_per_sec /=TEST_REPETITIONS ; tp->mbps /=TEST_REPETITIONS ; - ret |= (int )rte_atomic16_read (&tp->processing_status); + ret |= (int )__atomic_load_n (&tp->processing_status, +__ATOMIC_RELAXED); }/* Print throughput if test passed */ --2.17.1
PATCH 12/12 app: remove unnecessary include of atomic
In reply to Joyce KongRemove the unnecessary rte_atomic.h included in app module.
--- app/proc-info/main.c | 1 - app/test-pipeline/config.c | 1 - app/test-pipeline/init.c | 1 - app/test-pipeline/main.c | 1 - app/test-pipeline/runtime.c | 1 - app/test-pmd/cmdline.c | 1 - app/test-pmd/config.c | 1 - app/test-pmd/csumonly.c | 1 - app/test-pmd/flowgen.c | 1 - app/test-pmd/icmpecho.c | 1 - app/test-pmd/iofwd.c | 1 - app/test-pmd/macfwd.c | 1 - app/test-pmd/macswap.c | 1 - app/test-pmd/parameters.c | 1 - app/test-pmd/rxonly.c | 1 - app/test-pmd/txonly.c | 1 - app/test/test_barrier.c | 1 - app/test/test_mbuf.c | 1 - app/test/test_mp_secondary.c | 1 - app/test/test_ring.c | 1 - 20 files changed, 20 deletions(-)
app/proc-info/main.c +0 -1
@@ -27,7 +27,6 @@#include <rte_per_lcore.h> #include <rte_lcore.h> #include <rte_log.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_string_fns.h> #include <rte_metrics.h>
app/test-pipeline/config.c +0 -1
@@ -21,7 +21,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_launch.h> -#include <rte_atomic.h> #include <rte_cycles.h> #include <rte_prefetch.h> #include <rte_lcore.h>
app/test-pipeline/init.c +0 -1
@@ -21,7 +21,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_launch.h> -#include <rte_atomic.h> #include <rte_cycles.h> #include <rte_prefetch.h> #include <rte_lcore.h>
app/test-pipeline/main.c +0 -1
@@ -22,7 +22,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_launch.h> -#include <rte_atomic.h> #include <rte_cycles.h> #include <rte_prefetch.h> #include <rte_lcore.h>
app/test-pipeline/runtime.c +0 -1
@@ -21,7 +21,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_launch.h> -#include <rte_atomic.h> #include <rte_cycles.h> #include <rte_prefetch.h> #include <rte_branch_prediction.h>
app/test-pmd/cmdline.c +0 -1
@@ -24,7 +24,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_ring.h> #include <rte_mempool.h>
app/test-pmd/config.c +0 -1
@@ -27,7 +27,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_mempool.h> #include <rte_mbuf.h>
app/test-pmd/csumonly.c +0 -1
@@ -24,7 +24,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_mempool.h> #include <rte_mbuf.h>
app/test-pmd/flowgen.c +0 -1
@@ -24,7 +24,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_mempool.h> #include <rte_mbuf.h>
app/test-pmd/icmpecho.c +0 -1
@@ -20,7 +20,6 @@#include <rte_cycles.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_memory.h> #include <rte_mempool.h>
app/test-pmd/iofwd.c +0 -1
@@ -23,7 +23,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_memcpy.h> #include <rte_mempool.h>
app/test-pmd/macfwd.c +0 -1
@@ -24,7 +24,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_mempool.h> #include <rte_mbuf.h>
app/test-pmd/macswap.c +0 -1
@@ -24,7 +24,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_mempool.h> #include <rte_mbuf.h>
app/test-pmd/parameters.c +0 -1
@@ -30,7 +30,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_mempool.h> #include <rte_interrupts.h>
app/test-pmd/rxonly.c +0 -1
@@ -24,7 +24,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_mempool.h> #include <rte_mbuf.h>
app/test-pmd/txonly.c +0 -1
@@ -24,7 +24,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_mempool.h> #include <rte_mbuf.h>
app/test/test_barrier.c +0 -1
@@ -24,7 +24,6 @@#include <rte_memory.h> #include <rte_per_lcore.h> #include <rte_launch.h> -#include <rte_atomic.h> #include <rte_eal.h> #include <rte_lcore.h> #include <rte_pause.h>
app/test/test_mbuf.c +0 -1
@@ -21,7 +21,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_ring.h> #include <rte_mempool.h>
app/test/test_mp_secondary.c +0 -1
@@ -28,7 +28,6 @@#include <rte_lcore.h> #include <rte_errno.h> #include <rte_branch_prediction.h> -#include <rte_atomic.h> #include <rte_ring.h> #include <rte_debug.h> #include <rte_log.h>
app/test/test_ring.c +0 -1
@@ -20,7 +20,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_malloc.h> #include <rte_ring.h>
Signature · 1 line
2.17.1
Hi all,
Would you please help review the patch series?
Thanks!
Best Regards,
Joyce
Quoted 84 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Joyce Kong
Sent: Monday, August 2, 2021 6:19 PM
To: [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; nd <[email protected]>
Subject: [dpdk-dev] [PATCH v1 00/12] use compiler atomic builtins for appSince atomic operations have been adopted in DPDK now[1], change
rte_atomicNN_xxxAPIs to compiler's atomic built-ins in app module[2].[1] https://www.dpdk.org/blog/2021/03/26/dpdk-adopts-the-c11-memory-
model/
[2] https://doc.dpdk.org/guides/rel_notes/deprecation.htmlJoyce Kong (12):
test/pmd_perf: use compiler atomic builtins for polling sync test/ring_perf: use compiler atomic builtins for lcores sync test/timer: use compiler atomic builtins for sync test/stack_perf: use compiler atomics for lcore sync test/bpf: use compiler atomics for calculation test/func_reentrancy: use compiler atomic for data sync app/eventdev: use compiler atomic builtins for packets sync app/crypto: use compiler atomic builtins for display sync app/compress: use compiler atomic builtins for display sync app/testpmd: use compiler atomic builtins for port sync app/bbdev: use compiler atomics for thread sync
app: remove unnecessary include of atomicapp/proc-info/main.c | 1 - app/test-bbdev/test_bbdev_perf.c | 135 ++++++++---------- .../comp_perf_test_common.h | 2 +- .../comp_perf_test_cyclecount.c | 10 +- .../comp_perf_test_throughput.c | 11 +- .../comp_perf_test_verify.c | 6 +- app/test-crypto-perf/cperf_test_latency.c | 6 +- .../cperf_test_pmd_cyclecount.c | 9 +- app/test-crypto-perf/cperf_test_throughput.c | 9 +- app/test-crypto-perf/cperf_test_verify.c | 9 +- app/test-eventdev/evt_main.c | 1 - app/test-eventdev/test_order_atq.c | 4 +- app/test-eventdev/test_order_common.c | 4 +- app/test-eventdev/test_order_common.h | 8 +- app/test-eventdev/test_order_queue.c | 4 +- app/test-pipeline/config.c | 1 - app/test-pipeline/init.c | 1 - app/test-pipeline/main.c | 1 - app/test-pipeline/runtime.c | 1 - app/test-pmd/cmdline.c | 1 - app/test-pmd/config.c | 1 - app/test-pmd/csumonly.c | 1 - app/test-pmd/flowgen.c | 1 - app/test-pmd/icmpecho.c | 1 - app/test-pmd/iofwd.c | 1 - app/test-pmd/macfwd.c | 1 - app/test-pmd/macswap.c | 1 - app/test-pmd/parameters.c | 1 - app/test-pmd/rxonly.c | 1 - app/test-pmd/testpmd.c | 75 ++++++---- app/test-pmd/txonly.c | 1 - app/test/test_barrier.c | 1 - app/test/test_bpf.c | 28 ++-- app/test/test_func_reentrancy.c | 27 ++-- app/test/test_mbuf.c | 1 - app/test/test_mp_secondary.c | 1 - app/test/test_pmd_perf.c | 12 +- app/test/test_ring.c | 1 - app/test/test_ring_perf.c | 9 +- app/test/test_stack_perf.c | 14 +- app/test/test_timer.c | 28 ++-- app/test/test_timer_secondary.c | 1 - 42 files changed, 213 insertions(+), 219 deletions(-)--
2.17.1