From patchwork Wed Jun 16 02:54:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joyce Kong X-Patchwork-Id: 94260 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 84A32A0C45; Wed, 16 Jun 2021 04:55:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 69AEC410DE; Wed, 16 Jun 2021 04:55:43 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 853DB4003C for ; Wed, 16 Jun 2021 04:55:41 +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 F037A13A1; Tue, 15 Jun 2021 19:55:40 -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 D4C2A3F694; Tue, 15 Jun 2021 19:55:37 -0700 (PDT) From: Joyce Kong To: thomas@monjalon.net, david.marchand@redhat.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: Tue, 15 Jun 2021 21:54:52 -0500 Message-Id: <20210616025459.22717-2-joyce.kong@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210616025459.22717-1-joyce.kong@arm.com> References: <20210604094624.31308-1-joyce.kong@arm.com> <20210616025459.22717-1-joyce.kong@arm.com> Subject: [dpdk-dev] [PATCH v2 1/8] test/ticketlock: use GCC atomic builtins for lcores 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 GCC atomic builtins for lcores sync in ticketlock testcases. Signed-off-by: Joyce Kong Reviewed-by: Ruifeng Wang Reviewed-by: Honnappa Nagarahalli Acked-by: Stephen Hemminger --- app/test/test_ticketlock.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/test/test_ticketlock.c b/app/test/test_ticketlock.c index 7aab8665b..242c13647 100644 --- a/app/test/test_ticketlock.c +++ b/app/test/test_ticketlock.c @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -49,7 +48,7 @@ static rte_ticketlock_t tl_tab[RTE_MAX_LCORE]; static rte_ticketlock_recursive_t tlr; static unsigned int count; -static rte_atomic32_t synchro; +static uint32_t synchro; static int test_ticketlock_per_core(__rte_unused void *arg) @@ -112,8 +111,7 @@ load_loop_fn(void *func_param) /* wait synchro for workers */ if (lcore != rte_get_main_lcore()) - while (rte_atomic32_read(&synchro) == 0) - ; + rte_wait_until_equal_32(&synchro, 1, __ATOMIC_RELAXED); begin = rte_rdtsc_precise(); while (lcore_count[lcore] < MAX_LOOP) { @@ -155,11 +153,11 @@ test_ticketlock_perf(void) printf("\nTest with lock on %u cores...\n", rte_lcore_count()); /* Clear synchro and start workers */ - rte_atomic32_set(&synchro, 0); + __atomic_store_n(&synchro, 0, __ATOMIC_RELAXED); rte_eal_mp_remote_launch(load_loop_fn, &lock, SKIP_MAIN); /* start synchro and launch test on main */ - rte_atomic32_set(&synchro, 1); + __atomic_store_n(&synchro, 1, __ATOMIC_RELAXED); load_loop_fn(&lock); rte_eal_mp_wait_lcore();