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 16EEDA0C41; Wed, 17 Nov 2021 09:22:50 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2B3244115A; Wed, 17 Nov 2021 09:22:38 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 202E04115A for ; Wed, 17 Nov 2021 09:22:36 +0100 (CET) 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 A0AC86D; Wed, 17 Nov 2021 00:22:35 -0800 (PST) Received: from net-arm-n1amp-02.shanghai.arm.com (net-arm-n1amp-02.shanghai.arm.com [10.169.210.110]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8B8293F5A1; Wed, 17 Nov 2021 00:22:33 -0800 (PST) From: Joyce Kong To: Olivier Matz Cc: dev@dpdk.org, honnappa.nagarahalli@arm.com, nd@arm.com, Joyce Kong , Ruifeng Wang Subject: [PATCH v3 04/12] test/stack_perf: use compiler atomics for lcore sync Date: Wed, 17 Nov 2021 08:21:52 +0000 Message-Id: <20211117082200.1029621-5-joyce.kong@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117082200.1029621-1-joyce.kong@arm.com> References: <20211116094205.750359-1-joyce.kong@arm.com> <20211117082200.1029621-1-joyce.kong@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Convert rte_atomic usages to compiler atomic built-ins for lcore sync in stack_perf test cases. Signed-off-by: Joyce Kong Reviewed-by: Ruifeng Wang Reviewed-by: Honnappa Nagarahalli --- app/test/test_stack_perf.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/test/test_stack_perf.c b/app/test/test_stack_perf.c index 4ee40d5d19..1eae00a334 100644 --- a/app/test/test_stack_perf.c +++ b/app/test/test_stack_perf.c @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -24,7 +23,7 @@ */ static volatile unsigned int bulk_sizes[] = {8, MAX_BURST}; -static rte_atomic32_t lcore_barrier; +static uint32_t lcore_barrier; struct lcore_pair { unsigned int c1; @@ -144,9 +143,8 @@ bulk_push_pop(void *p) s = args->s; size = args->sz; - rte_atomic32_sub(&lcore_barrier, 1); - while (rte_atomic32_read(&lcore_barrier) != 0) - rte_pause(); + __atomic_fetch_sub(&lcore_barrier, 1, __ATOMIC_RELAXED); + rte_wait_until_equal_32(&lcore_barrier, 0, __ATOMIC_RELAXED); uint64_t start = rte_rdtsc(); @@ -175,7 +173,7 @@ run_on_core_pair(struct lcore_pair *cores, struct rte_stack *s, unsigned int i; for (i = 0; i < RTE_DIM(bulk_sizes); i++) { - rte_atomic32_set(&lcore_barrier, 2); + __atomic_store_n(&lcore_barrier, 2, __ATOMIC_RELAXED); args[0].sz = args[1].sz = bulk_sizes[i]; args[0].s = args[1].s = s; @@ -208,7 +206,7 @@ run_on_n_cores(struct rte_stack *s, lcore_function_t fn, int n) int cnt = 0; double avg; - rte_atomic32_set(&lcore_barrier, n); + __atomic_store_n(&lcore_barrier, n, __ATOMIC_RELAXED); RTE_LCORE_FOREACH_WORKER(lcore_id) { if (++cnt >= n) @@ -302,7 +300,7 @@ __test_stack_perf(uint32_t flags) struct lcore_pair cores; struct rte_stack *s; - rte_atomic32_init(&lcore_barrier); + __atomic_store_n(&lcore_barrier, 0, __ATOMIC_RELAXED); s = rte_stack_create(STACK_NAME, STACK_SIZE, rte_socket_id(), flags); if (s == NULL) { -- 2.25.1