From: Joyce Kong <joyce.kong@arm.com>
Cc: dev@dpdk.org, thomas@monjalon.net, david.marchand@redhat.com,
honnappa.nagarahalli@arm.com, ruifeng.wang@arm.com, nd@arm.com
Subject: [dpdk-dev] [PATCH v1 5/8] examples/l2fwd-jobstats: use compiler atomics for stats sync
Date: Thu, 19 Aug 2021 02:09:05 -0500 [thread overview]
Message-ID: <20210819070908.25773-6-joyce.kong@arm.com> (raw)
In-Reply-To: <20210819070908.25773-1-joyce.kong@arm.com>
Convert rte_atomic usages to compiler atomic built-ins
for stats_read_pending sync in l2fwd_jobstats module.
Signed-off-by: Joyce Kong <joyce.kong@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
examples/l2fwd-jobstats/main.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/examples/l2fwd-jobstats/main.c b/examples/l2fwd-jobstats/main.c
index bbb4a27a6d..99a17de181 100644
--- a/examples/l2fwd-jobstats/main.c
+++ b/examples/l2fwd-jobstats/main.c
@@ -16,7 +16,6 @@
#include <rte_memcpy.h>
#include <rte_eal.h>
#include <rte_launch.h>
-#include <rte_atomic.h>
#include <rte_cycles.h>
#include <rte_prefetch.h>
#include <rte_lcore.h>
@@ -81,7 +80,7 @@ struct lcore_queue_conf {
struct rte_jobstats idle_job;
struct rte_jobstats_context jobs_context;
- rte_atomic16_t stats_read_pending;
+ uint16_t stats_read_pending;
rte_spinlock_t lock;
} __rte_cache_aligned;
/* >8 End of list of queues to be polled for given lcore. */
@@ -155,9 +154,9 @@ show_lcore_stats(unsigned lcore_id)
uint64_t collection_time = rte_get_timer_cycles();
/* Ask forwarding thread to give us stats. */
- rte_atomic16_set(&qconf->stats_read_pending, 1);
+ __atomic_store_n(&qconf->stats_read_pending, 1, __ATOMIC_RELAXED);
rte_spinlock_lock(&qconf->lock);
- rte_atomic16_set(&qconf->stats_read_pending, 0);
+ __atomic_store_n(&qconf->stats_read_pending, 0, __ATOMIC_RELAXED);
/* Collect context statistics. */
stats_period = ctx->state_time - ctx->start_time;
@@ -526,8 +525,8 @@ l2fwd_main_loop(void)
repeats++;
need_manage = qconf->flush_timer.expire < now;
/* Check if we was esked to give a stats. */
- stats_read_pending =
- rte_atomic16_read(&qconf->stats_read_pending);
+ stats_read_pending = __atomic_load_n(&qconf->stats_read_pending,
+ __ATOMIC_RELAXED);
need_manage |= stats_read_pending;
for (i = 0; i < qconf->n_rx_port && !need_manage; i++)
--
2.17.1
next prev parent reply other threads:[~2021-08-19 7:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-19 7:09 [dpdk-dev] [PATCH v1 0/8] use compiler atomic builtins for examples Joyce Kong
2021-08-19 7:09 ` [dpdk-dev] [PATCH v1 1/8] examples/bbdev_app: use compiler atomics for flag sync Joyce Kong
2021-08-19 7:09 ` [dpdk-dev] [PATCH v1 2/8] examples/multi_process: use compiler atomics for sync Joyce Kong
2021-08-19 7:09 ` [dpdk-dev] [PATCH v1 3/8] examples/kni: use compiler atomics for status sync Joyce Kong
2021-08-19 7:09 ` [dpdk-dev] [PATCH v1 4/8] examples/performance-thread: use compiler atomics for sync Joyce Kong
2021-08-19 7:09 ` Joyce Kong [this message]
2021-08-19 7:09 ` [dpdk-dev] [PATCH v1 6/8] examples/vm_power_manager: " Joyce Kong
2021-08-19 7:09 ` [dpdk-dev] [PATCH v1 7/8] examples/server_node_efd: " Joyce Kong
2021-08-19 7:09 ` [dpdk-dev] [PATCH v1 8/8] examples: remove unnecessary include of atomic Joyce Kong
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=20210819070908.25773-6-joyce.kong@arm.com \
--to=joyce.kong@arm.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=honnappa.nagarahalli@arm.com \
--cc=nd@arm.com \
--cc=ruifeng.wang@arm.com \
--cc=thomas@monjalon.net \
/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).