From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id B11E3A0C43;
	Tue, 20 Jul 2021 05:52:33 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 4882F4117E;
	Tue, 20 Jul 2021 05:52:24 +0200 (CEST)
Received: from foss.arm.com (foss.arm.com [217.140.110.172])
 by mails.dpdk.org (Postfix) with ESMTP id 424694117E
 for <dev@dpdk.org>; Tue, 20 Jul 2021 05:52:22 +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 AE60D1FB;
 Mon, 19 Jul 2021 20:52:21 -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 56A6D3F694;
 Mon, 19 Jul 2021 20:52:18 -0700 (PDT)
From: Joyce Kong <joyce.kong@arm.com>
To: thomas@monjalon.net, david.marchand@redhat.com,
 roretzla@linux.microsoft.com, stephen@networkplumber.org,
 olivier.matz@6wind.com, andrew.rybchenko@oktetlabs.ru,
 harry.van.haaren@intel.com, honnappa.nagarahalli@arm.com,
 ruifeng.wang@arm.com
Cc: dev@dpdk.org,
	nd@arm.com
Date: Mon, 19 Jul 2021 22:51:23 -0500
Message-Id: <20210720035125.14214-7-joyce.kong@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20210720035125.14214-1-joyce.kong@arm.com>
References: <20210616025459.22717-1-joyce.kong@arm.com>
 <20210720035125.14214-1-joyce.kong@arm.com>
Subject: [dpdk-dev] [PATCH v3 6/8] test/mempool_perf: use compiler atomics
 for lcores sync
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

Convert rte_atomic usages to compiler atomic built-ins for lcores
sync in mempool_perf testcases. Meanwhile, remove unnecessary
synchro init as it would be set to 0 when launching cores.

Signed-off-by: Joyce Kong <joyce.kong@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_mempool_perf.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/app/test/test_mempool_perf.c b/app/test/test_mempool_perf.c
index d7d0aaa334..8f629736e8 100644
--- a/app/test/test_mempool_perf.c
+++ b/app/test/test_mempool_perf.c
@@ -20,7 +20,6 @@
 #include <rte_eal.h>
 #include <rte_per_lcore.h>
 #include <rte_lcore.h>
-#include <rte_atomic.h>
 #include <rte_branch_prediction.h>
 #include <rte_mempool.h>
 #include <rte_spinlock.h>
@@ -83,7 +82,7 @@
 static int use_external_cache;
 static unsigned external_cache_size = RTE_MEMPOOL_CACHE_MAX_SIZE;
 
-static rte_atomic32_t synchro;
+static uint32_t synchro;
 
 /* number of objects in one bulk operation (get or put) */
 static unsigned n_get_bulk;
@@ -145,7 +144,7 @@ per_lcore_mempool_test(void *arg)
 
 	/* wait synchro for workers */
 	if (lcore_id != rte_get_main_lcore())
-		while (rte_atomic32_read(&synchro) == 0);
+		rte_wait_until_equal_32(&synchro, 1, __ATOMIC_RELAXED);
 
 	start_cycles = rte_get_timer_cycles();
 
@@ -198,7 +197,7 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)
 	int ret;
 	unsigned cores_save = cores;
 
-	rte_atomic32_set(&synchro, 0);
+	__atomic_store_n(&synchro, 0, __ATOMIC_RELAXED);
 
 	/* reset stats */
 	memset(stats, 0, sizeof(stats));
@@ -223,7 +222,7 @@ launch_cores(struct rte_mempool *mp, unsigned int cores)
 	}
 
 	/* start synchro and launch test on main */
-	rte_atomic32_set(&synchro, 1);
+	__atomic_store_n(&synchro, 1, __ATOMIC_RELAXED);
 
 	ret = per_lcore_mempool_test(mp);
 
@@ -288,8 +287,6 @@ test_mempool_perf(void)
 	const char *default_pool_ops;
 	int ret = -1;
 
-	rte_atomic32_init(&synchro);
-
 	/* create a mempool (without cache) */
 	mp_nocache = rte_mempool_create("perf_test_nocache", MEMPOOL_SIZE,
 					MEMPOOL_ELT_SIZE, 0, 0,
-- 
2.17.1