DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dharmik Thakkar <dharmik.thakkar@arm.com>
To: Nicolas Chautru <nicolas.chautru@intel.com>
Cc: dev@dpdk.org, nd@arm.com, honnappa.nagarahalli@arm.com,
	ruifeng.wang@arm.com, joyce.kong@arm.com,
	dharmik.thakkar@arm.com
Subject: [dpdk-dev] [PATCH v3 1/8] examples/bbdev_app: use compiler atomics for flag sync
Date: Wed, 13 Oct 2021 13:54:00 -0500
Message-ID: <20211013185407.2841183-2-dharmik.thakkar@arm.com> (raw)
In-Reply-To: <20211013185407.2841183-1-dharmik.thakkar@arm.com>

From: Joyce Kong <joyce.kong@arm.com>

Convert rte_atomic usages to compiler atomic built-ins
for global_exit_flag sync.

Signed-off-by: Joyce Kong <joyce.kong@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 examples/bbdev_app/main.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/examples/bbdev_app/main.c b/examples/bbdev_app/main.c
index adbd40808396..95fd0b814494 100644
--- a/examples/bbdev_app/main.c
+++ b/examples/bbdev_app/main.c
@@ -18,7 +18,6 @@
 #include <getopt.h>
 #include <signal.h>
 
-#include <rte_atomic.h>
 #include <rte_common.h>
 #include <rte_eal.h>
 #include <rte_cycles.h>
@@ -167,7 +166,7 @@ static const struct app_config_params def_app_config = {
 	.num_dec_cores = 1,
 };
 
-static rte_atomic16_t global_exit_flag;
+static uint16_t global_exit_flag;
 
 /* display usage */
 static inline void
@@ -279,7 +278,7 @@ static void
 signal_handler(int signum)
 {
 	printf("\nSignal %d received\n", signum);
-	rte_atomic16_set(&global_exit_flag, 1);
+	__atomic_store_n(&global_exit_flag, 1, __ATOMIC_RELAXED);
 }
 
 static void
@@ -323,7 +322,7 @@ check_port_link_status(uint16_t port_id)
 	fflush(stdout);
 
 	for (count = 0; count <= MAX_CHECK_TIME &&
-			!rte_atomic16_read(&global_exit_flag); count++) {
+			!__atomic_load_n(&global_exit_flag, __ATOMIC_RELAXED); count++) {
 		memset(&link, 0, sizeof(link));
 		link_get_err = rte_eth_link_get_nowait(port_id, &link);
 
@@ -677,7 +676,7 @@ stats_loop(void *arg)
 {
 	struct stats_lcore_params *stats_lcore = arg;
 
-	while (!rte_atomic16_read(&global_exit_flag)) {
+	while (!__atomic_load_n(&global_exit_flag, __ATOMIC_RELAXED)) {
 		print_stats(stats_lcore);
 		rte_delay_ms(500);
 	}
@@ -923,7 +922,7 @@ processing_loop(void *arg)
 	const bool run_decoder = (lcore_conf->core_type &
 			(1 << RTE_BBDEV_OP_TURBO_DEC));
 
-	while (!rte_atomic16_read(&global_exit_flag)) {
+	while (!__atomic_load_n(&global_exit_flag, __ATOMIC_RELAXED)) {
 		if (run_encoder)
 			run_encoding(lcore_conf);
 		if (run_decoder)
@@ -1057,7 +1056,7 @@ main(int argc, char **argv)
 		.align = __alignof__(struct rte_mbuf *),
 	};
 
-	rte_atomic16_init(&global_exit_flag);
+	__atomic_store_n(&global_exit_flag, 0, __ATOMIC_RELAXED);
 
 	sigret = signal(SIGTERM, signal_handler);
 	if (sigret == SIG_ERR)
-- 
2.25.1


  reply	other threads:[~2021-10-13 18:54 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23  5:49 [dpdk-dev] [PATCH v2 0/8] use compiler atomic builtins for examples Joyce Kong
2021-08-23  5:49 ` [dpdk-dev] [PATCH v2 1/8] examples/bbdev_app: use compiler atomics for flag sync Joyce Kong
2021-08-23  5:49 ` [dpdk-dev] [PATCH v2 2/8] examples/multi_process: use compiler atomics for sync Joyce Kong
2021-08-23  5:49 ` [dpdk-dev] [PATCH v2 3/8] examples/kni: use compiler atomics for status sync Joyce Kong
2021-08-23  5:49 ` [dpdk-dev] [PATCH v2 4/8] examples/performance-thread: use compiler atomics for sync Joyce Kong
2021-08-23  5:49 ` [dpdk-dev] [PATCH v2 5/8] examples/l2fwd-jobstats: use compiler atomics for stats sync Joyce Kong
2021-08-23  5:49 ` [dpdk-dev] [PATCH v2 6/8] examples/vm_power_manager: use compiler atomics for sync Joyce Kong
2021-08-23  5:49 ` [dpdk-dev] [PATCH v2 7/8] examples/server_node_efd: " Joyce Kong
2021-08-23  5:49 ` [dpdk-dev] [PATCH v2 8/8] examples: remove unnecessary include of atomic Joyce Kong
2021-08-23 11:29   ` Xia, Chenbo
2021-08-24  2:30     ` Joyce Kong
2021-10-13 18:53 ` [dpdk-dev] [PATCH v3 0/8] use compiler atomic builtins for examples Dharmik Thakkar
2021-10-13 18:54   ` Dharmik Thakkar [this message]
2021-10-13 18:54   ` [dpdk-dev] [PATCH v3 2/8] examples/multi_process: use compiler atomics for sync Dharmik Thakkar
2021-10-13 18:54   ` [dpdk-dev] [PATCH v3 3/8] examples/kni: use compiler atomics for status sync Dharmik Thakkar
2021-10-13 18:54   ` [dpdk-dev] [PATCH v3 4/8] examples/performance-thread: use compiler atomics for sync Dharmik Thakkar
2021-10-13 18:54   ` [dpdk-dev] [PATCH v3 5/8] examples/l2fwd-jobstats: use compiler atomics for stats sync Dharmik Thakkar
2021-10-13 18:54   ` [dpdk-dev] [PATCH v3 6/8] examples/vm_power_manager: use compiler atomics for sync Dharmik Thakkar
2021-10-13 18:54   ` [dpdk-dev] [PATCH v3 7/8] examples/server_node_efd: " Dharmik Thakkar
2021-10-13 18:54   ` [dpdk-dev] [PATCH v3 8/8] examples: remove unnecessary include of atomic Dharmik Thakkar
2021-10-15 23:30     ` Dharmik Thakkar
2021-10-19 15:12       ` David Marchand
2021-10-19 15:12   ` [dpdk-dev] [PATCH v3 0/8] use compiler atomic builtins for examples David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211013185407.2841183-2-dharmik.thakkar@arm.com \
    --to=dharmik.thakkar@arm.com \
    --cc=dev@dpdk.org \
    --cc=honnappa.nagarahalli@arm.com \
    --cc=joyce.kong@arm.com \
    --cc=nd@arm.com \
    --cc=nicolas.chautru@intel.com \
    --cc=ruifeng.wang@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git