From patchwork Tue Nov 16 09:41:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joyce Kong X-Patchwork-Id: 104383 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B94CAA0C43; Tue, 16 Nov 2021 10:43:08 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E3594411AE; Tue, 16 Nov 2021 10:43:00 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 2CD43411AB for ; Tue, 16 Nov 2021 10:43:00 +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 AAF30ED1; Tue, 16 Nov 2021 01:42:59 -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 967253F5A1; Tue, 16 Nov 2021 01:42:57 -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 v2 04/12] test/stack_perf: use compiler atomics for lcore sync Date: Tue, 16 Nov 2021 09:41:57 +0000 Message-Id: <20211116094205.750359-5-joyce.kong@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116094205.750359-1-joyce.kong@arm.com> References: <20211116094205.750359-1-joyce.kong@arm.com> MIME-Version: 1.0 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) {