diff mbox series

[v1,02/12] test/ring_perf: use compiler atomic builtins for lcores sync

Message ID 20210802101847.3462-3-joyce.kong@arm.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series use compiler atomic builtins for app | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Joyce Kong Aug. 2, 2021, 10:18 a.m. UTC
Convert rte_atomic usages to compiler atomic built-ins
for lcores sync in ring_perf test cases.

Signed-off-by: Joyce Kong <joyce.kong@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 app/test/test_ring_perf.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Honnappa Nagarahalli Nov. 9, 2021, 5:43 a.m. UTC | #1
<snip>

> 
> Convert rte_atomic usages to compiler atomic built-ins for lcores sync in
> ring_perf test cases.
> 
> Signed-off-by: Joyce Kong <joyce.kong@arm.com>
> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
Looks good.
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>

> ---
>  app/test/test_ring_perf.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/app/test/test_ring_perf.c b/app/test/test_ring_perf.c index
> fd82e20412..2d8bb675a3 100644
> --- a/app/test/test_ring_perf.c
> +++ b/app/test/test_ring_perf.c
> @@ -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, &param, 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(&param);
> 
>  		rte_eal_mp_wait_lcore();
> --
> 2.17.1
diff mbox series

Patch

diff --git a/app/test/test_ring_perf.c b/app/test/test_ring_perf.c
index fd82e20412..2d8bb675a3 100644
--- a/app/test/test_ring_perf.c
+++ b/app/test/test_ring_perf.c
@@ -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, &param, 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(&param);
 
 		rte_eal_mp_wait_lcore();