From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 97677A0C56; Mon, 23 Aug 2021 07:50:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CB53241161; Mon, 23 Aug 2021 07:50:30 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id F1EFB41163 for ; Mon, 23 Aug 2021 07:50:28 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 788961042; Sun, 22 Aug 2021 22:50:28 -0700 (PDT) Received: from net-arm-n1sdp.shanghai.arm.com (net-arm-n1sdp.shanghai.arm.com [10.169.208.222]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 622DE3F5A1; Sun, 22 Aug 2021 22:50:26 -0700 (PDT) From: Joyce Kong To: Cc: dev@dpdk.org, thomas@monjalon.net, david.marchand@redhat.com, honnappa.nagarahalli@arm.com, ruifeng.wang@arm.com, nd@arm.com Date: Mon, 23 Aug 2021 00:49:49 -0500 Message-Id: <20210823054952.15001-6-joyce.kong@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210823054952.15001-1-joyce.kong@arm.com> References: <20210823054952.15001-1-joyce.kong@arm.com> Subject: [dpdk-dev] [PATCH v2 5/8] examples/l2fwd-jobstats: use compiler atomics for stats sync X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Convert rte_atomic usages to compiler atomic built-ins for stats_read_pending sync in l2fwd_jobstats module. Signed-off-by: Joyce Kong Reviewed-by: Ruifeng Wang --- 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 #include #include -#include #include #include #include @@ -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