DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dharmik Thakkar <dharmik.thakkar@arm.com>
To: Byron Marohn <byron.marohn@intel.com>,
	Yipeng Wang <yipeng1.wang@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 7/8] examples/server_node_efd: use compiler atomics for sync
Date: Wed, 13 Oct 2021 13:54:06 -0500	[thread overview]
Message-ID: <20211013185407.2841183-8-dharmik.thakkar@arm.com> (raw)
In-Reply-To: <20211013185407.2841183-1-dharmik.thakkar@arm.com>

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

Convert rte_atomic32_test_and_set to compiler CAS atomic
operation for display_stats sync.

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

diff --git a/examples/server_node_efd/server/main.c b/examples/server_node_efd/server/main.c
index 0d0d5679e4c4..fd72882e3a1c 100644
--- a/examples/server_node_efd/server/main.c
+++ b/examples/server_node_efd/server/main.c
@@ -22,7 +22,6 @@
 #include <rte_per_lcore.h>
 #include <rte_lcore.h>
 #include <rte_branch_prediction.h>
-#include <rte_atomic.h>
 #include <rte_ring.h>
 #include <rte_log.h>
 #include <rte_debug.h>
@@ -178,10 +177,12 @@ static int
 sleep_lcore(__rte_unused void *dummy)
 {
 	/* Used to pick a display thread - static, so zero-initialised */
-	static rte_atomic32_t display_stats;
+	static uint32_t display_stats;
 
 	/* Only one core should display stats */
-	if (rte_atomic32_test_and_set(&display_stats)) {
+	uint32_t display_init = 0;
+	if (__atomic_compare_exchange_n(&display_stats, &display_init, 1, 0,
+			__ATOMIC_RELAXED, __ATOMIC_RELAXED)) {
 		const unsigned int sleeptime = 1;
 
 		printf("Core %u displaying statistics\n", rte_lcore_id());
-- 
2.25.1


  parent reply	other threads:[~2021-10-13 18:55 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   ` [dpdk-dev] [PATCH v3 1/8] examples/bbdev_app: use compiler atomics for flag sync Dharmik Thakkar
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   ` Dharmik Thakkar [this message]
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-8-dharmik.thakkar@arm.com \
    --to=dharmik.thakkar@arm.com \
    --cc=byron.marohn@intel.com \
    --cc=dev@dpdk.org \
    --cc=honnappa.nagarahalli@arm.com \
    --cc=joyce.kong@arm.com \
    --cc=nd@arm.com \
    --cc=ruifeng.wang@arm.com \
    --cc=yipeng1.wang@intel.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).