From patchwork Wed Jul 7 05:48:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruifeng Wang X-Patchwork-Id: 95448 X-Patchwork-Delegate: thomas@monjalon.net 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 37BE9A0C48; Wed, 7 Jul 2021 07:49:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2118141413; Wed, 7 Jul 2021 07:49:08 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id DBA5E4069E for ; Wed, 7 Jul 2021 07:49:06 +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 605E5D6E; Tue, 6 Jul 2021 22:49:06 -0700 (PDT) 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 3FD993F5A1; Tue, 6 Jul 2021 22:49:02 -0700 (PDT) From: Ruifeng Wang To: Cc: dev@dpdk.org, david.marchand@redhat.com, thomas@monjalon.net, bruce.richardson@intel.com, jerinj@marvell.com, nd@arm.com, honnappa.nagarahalli@arm.com, ruifeng.wang@arm.com, Gavin Hu , Phil Yang , Steve Capper , Ola Liljedahl , Pavan Nikhilesh , Konstantin Ananyev Date: Wed, 7 Jul 2021 13:48:37 +0800 Message-Id: <20210707054840.1608425-2-ruifeng.wang@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210707054840.1608425-1-ruifeng.wang@arm.com> References: <20200424070741.16619-1-gavin.hu@arm.com> <20210707054840.1608425-1-ruifeng.wang@arm.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v4 1/3] spinlock: use wfe to reduce contention on aarch64 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" From: Gavin Hu In acquiring a spinlock, cores repeatedly poll the lock variable. This is replaced by rte_wait_until_equal API. Running the micro benchmarking and the testpmd and l3fwd traffic tests on ThunderX2, Ampere eMAG80 and Arm N1SDP, everything went well and no notable performance gain nor degradation was measured. Signed-off-by: Gavin Hu Reviewed-by: Ruifeng Wang Reviewed-by: Phil Yang Reviewed-by: Steve Capper Reviewed-by: Ola Liljedahl Reviewed-by: Honnappa Nagarahalli Tested-by: Pavan Nikhilesh Acked-by: Konstantin Ananyev Acked-by: Jerin Jacob --- lib/eal/include/generic/rte_spinlock.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/eal/include/generic/rte_spinlock.h b/lib/eal/include/generic/rte_spinlock.h index 87ae7a4f18..40fe49d5ad 100644 --- a/lib/eal/include/generic/rte_spinlock.h +++ b/lib/eal/include/generic/rte_spinlock.h @@ -65,8 +65,8 @@ rte_spinlock_lock(rte_spinlock_t *sl) while (!__atomic_compare_exchange_n(&sl->locked, &exp, 1, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { - while (__atomic_load_n(&sl->locked, __ATOMIC_RELAXED)) - rte_pause(); + rte_wait_until_equal_32((volatile uint32_t *)&sl->locked, + 0, __ATOMIC_RELAXED); exp = 0; } } From patchwork Wed Jul 7 05:48:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruifeng Wang X-Patchwork-Id: 95449 X-Patchwork-Delegate: thomas@monjalon.net 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 575AAA0C48; Wed, 7 Jul 2021 07:49:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 427D341446; Wed, 7 Jul 2021 07:49:14 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 11C524069E for ; Wed, 7 Jul 2021 07:49:13 +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 735FBD6E; Tue, 6 Jul 2021 22:49:12 -0700 (PDT) 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 D297A3F5A1; Tue, 6 Jul 2021 22:49:08 -0700 (PDT) From: Ruifeng Wang To: Honnappa Nagarahalli , Konstantin Ananyev Cc: dev@dpdk.org, david.marchand@redhat.com, thomas@monjalon.net, bruce.richardson@intel.com, jerinj@marvell.com, nd@arm.com, ruifeng.wang@arm.com, Gavin Hu , Steve Capper , Ola Liljedahl Date: Wed, 7 Jul 2021 13:48:38 +0800 Message-Id: <20210707054840.1608425-3-ruifeng.wang@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210707054840.1608425-1-ruifeng.wang@arm.com> References: <20200424070741.16619-1-gavin.hu@arm.com> <20210707054840.1608425-1-ruifeng.wang@arm.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v4 2/3] ring: use wfe to wait for ring tail update on aarch64 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" Instead of polling for tail to be updated, use wfe instruction. Signed-off-by: Gavin Hu Signed-off-by: Ruifeng Wang Reviewed-by: Steve Capper Reviewed-by: Ola Liljedahl Reviewed-by: Honnappa Nagarahalli Acked-by: Konstantin Ananyev Acked-by: Jerin Jacob --- lib/ring/rte_ring_c11_pvt.h | 4 ++-- lib/ring/rte_ring_generic_pvt.h | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/ring/rte_ring_c11_pvt.h b/lib/ring/rte_ring_c11_pvt.h index 759192f4c4..37e0b2afd6 100644 --- a/lib/ring/rte_ring_c11_pvt.h +++ b/lib/ring/rte_ring_c11_pvt.h @@ -2,6 +2,7 @@ * * Copyright (c) 2017,2018 HXT-semitech Corporation. * Copyright (c) 2007-2009 Kip Macy kmacy@freebsd.org + * Copyright (c) 2021 Arm Limited * All rights reserved. * Derived from FreeBSD's bufring.h * Used as BSD-3 Licensed with permission from Kip Macy. @@ -21,8 +22,7 @@ __rte_ring_update_tail(struct rte_ring_headtail *ht, uint32_t old_val, * we need to wait for them to complete */ if (!single) - while (unlikely(ht->tail != old_val)) - rte_pause(); + rte_wait_until_equal_32(&ht->tail, old_val, __ATOMIC_RELAXED); __atomic_store_n(&ht->tail, new_val, __ATOMIC_RELEASE); } diff --git a/lib/ring/rte_ring_generic_pvt.h b/lib/ring/rte_ring_generic_pvt.h index 532deb5e7a..c95ad7e12c 100644 --- a/lib/ring/rte_ring_generic_pvt.h +++ b/lib/ring/rte_ring_generic_pvt.h @@ -23,8 +23,7 @@ __rte_ring_update_tail(struct rte_ring_headtail *ht, uint32_t old_val, * we need to wait for them to complete */ if (!single) - while (unlikely(ht->tail != old_val)) - rte_pause(); + rte_wait_until_equal_32(&ht->tail, old_val, __ATOMIC_RELAXED); ht->tail = new_val; } From patchwork Wed Jul 7 05:48:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruifeng Wang X-Patchwork-Id: 95450 X-Patchwork-Delegate: thomas@monjalon.net 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 6D20FA0C48; Wed, 7 Jul 2021 07:49:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5B7C94145B; Wed, 7 Jul 2021 07:49:19 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 42AA24145B for ; Wed, 7 Jul 2021 07:49:18 +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 BCDCFD6E; Tue, 6 Jul 2021 22:49:17 -0700 (PDT) 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 E37983F5A1; Tue, 6 Jul 2021 22:49:14 -0700 (PDT) From: Ruifeng Wang To: Jan Viktorin , Ruifeng Wang , Jerin Jacob , Bruce Richardson Cc: dev@dpdk.org, david.marchand@redhat.com, thomas@monjalon.net, nd@arm.com, honnappa.nagarahalli@arm.com Date: Wed, 7 Jul 2021 13:48:39 +0800 Message-Id: <20210707054840.1608425-4-ruifeng.wang@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210707054840.1608425-1-ruifeng.wang@arm.com> References: <20200424070741.16619-1-gavin.hu@arm.com> <20210707054840.1608425-1-ruifeng.wang@arm.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v4 3/3] build: add option to enable wait until equal 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" Introduce a meson option 'use_wfe' to select wait until equal method. The default is disable. Traditional polling loop is used. When enabled, architecture specific mechanism is relied on to do the wait. Signed-off-by: Ruifeng Wang --- config/arm/meson.build | 2 +- meson_options.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config/arm/meson.build b/config/arm/meson.build index 9b147c0b93..9ea478fb77 100644 --- a/config/arm/meson.build +++ b/config/arm/meson.build @@ -18,7 +18,6 @@ flags_common = [ # ['RTE_ARM64_MEMCPY_STRICT_ALIGN', false], ['RTE_SCHED_VECTOR', false], - ['RTE_ARM_USE_WFE', false], ['RTE_ARCH_ARM64', true], ['RTE_CACHE_LINE_SIZE', 128] ] @@ -371,6 +370,7 @@ socs = { dpdk_conf.set('RTE_ARCH_ARM', 1) dpdk_conf.set('RTE_FORCE_INTRINSICS', 1) +dpdk_conf.set('RTE_ARM_USE_WFE', get_option('use_wfe')) if dpdk_conf.get('RTE_ARCH_32') # armv7 build diff --git a/meson_options.txt b/meson_options.txt index 56bdfd0f0a..5012803c77 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -44,3 +44,5 @@ option('tests', type: 'boolean', value: true, description: 'build unit tests') option('use_hpet', type: 'boolean', value: false, description: 'use HPET timer in EAL') +option('use_wfe', type: 'boolean', value: false, description: + 'use Wait Until Equal for polling loops')