From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by dpdk.org (Postfix) with ESMTP id 14C2D2BF4 for ; Fri, 29 Mar 2019 11:56:57 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7AD0615BF; Fri, 29 Mar 2019 03:56:56 -0700 (PDT) Received: from phil-VirtualBox.shanghai.arm.com (unknown [10.169.106.173]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 064403F575; Fri, 29 Mar 2019 03:56:54 -0700 (PDT) From: Phil Yang To: dev@dpdk.org, thomas@monjalon.net Cc: david.hunt@intel.com, reshma.pattan@intel.com, gavin.hu@arm.com, honnappa.nagarahalli@arm.com, phil.yang@arm.com, nd@arm.com Date: Fri, 29 Mar 2019 18:56:38 +0800 Message-Id: <1553856998-25394-4-git-send-email-phil.yang@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1553856998-25394-1-git-send-email-phil.yang@arm.com> References: <1553856998-25394-1-git-send-email-phil.yang@arm.com> In-Reply-To: <1546508946-12552-1-git-send-email-phil.yang@arm.com> References: <1546508946-12552-1-git-send-email-phil.yang@arm.com> Subject: [dpdk-dev] [PATCH v2 3/3] test/ring_perf: replace sync builtins with atomic builtins X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Mar 2019 10:56:57 -0000 '__sync' built-in functions are deprecated, should use the '__atomic' built-in instead. the sync built-in functions are full barriers, while atomic built-in functions offer less restrictive one-way barriers, which help performance. Here is the example test result on TX2: sudo ./arm64-armv8a-linuxapp-gcc/app/test -c 0x7fffffe \ -n 4 --socket-mem=1024,0 --file-prefix=~ -- -i RTE>>ring_perf_autotest *** ring_perf_autotest without this patch *** SP/SC bulk enq/dequeue (size: 8): 6.22 MP/MC bulk enq/dequeue (size: 8): 11.50 SP/SC bulk enq/dequeue (size: 32): 1.85 MP/MC bulk enq/dequeue (size: 32): 2.66 *** ring_perf_autotest with this patch *** SP/SC bulk enq/dequeue (size: 8): 6.13 MP/MC bulk enq/dequeue (size: 8): 9.83 SP/SC bulk enq/dequeue (size: 32): 1.96 MP/MC bulk enq/dequeue (size: 32): 2.30 So for the ring performance test, this patch improved 11% of ring operations performance. Signed-off-by: Phil Yang Reviewed-by: Gavin Hu Reviewed-by: Joyce Kong Reviewed-by: Dharmik Thakkar --- app/test/test_ring_perf.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/test/test_ring_perf.c b/app/test/test_ring_perf.c index ebb3939..e851c1a 100644 --- a/app/test/test_ring_perf.c +++ b/app/test/test_ring_perf.c @@ -160,7 +160,11 @@ enqueue_bulk(void *p) unsigned i; void *burst[MAX_BURST] = {0}; - if ( __sync_add_and_fetch(&lcore_count, 1) != 2 ) +#ifdef RTE_USE_C11_MEM_MODEL + if (__atomic_add_fetch(&lcore_count, 1, __ATOMIC_RELAXED) != 2) +#else + if (__sync_add_and_fetch(&lcore_count, 1) != 2) +#endif while(lcore_count != 2) rte_pause(); @@ -196,7 +200,11 @@ dequeue_bulk(void *p) unsigned i; void *burst[MAX_BURST] = {0}; - if ( __sync_add_and_fetch(&lcore_count, 1) != 2 ) +#ifdef RTE_USE_C11_MEM_MODEL + if (__atomic_add_fetch(&lcore_count, 1, __ATOMIC_RELAXED) != 2) +#else + if (__sync_add_and_fetch(&lcore_count, 1) != 2) +#endif while(lcore_count != 2) rte_pause(); -- 2.7.4 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 416BFA05D3 for ; Fri, 29 Mar 2019 11:57:15 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 31FA74CA9; Fri, 29 Mar 2019 11:57:04 +0100 (CET) Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by dpdk.org (Postfix) with ESMTP id 14C2D2BF4 for ; Fri, 29 Mar 2019 11:56:57 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7AD0615BF; Fri, 29 Mar 2019 03:56:56 -0700 (PDT) Received: from phil-VirtualBox.shanghai.arm.com (unknown [10.169.106.173]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 064403F575; Fri, 29 Mar 2019 03:56:54 -0700 (PDT) From: Phil Yang To: dev@dpdk.org, thomas@monjalon.net Cc: david.hunt@intel.com, reshma.pattan@intel.com, gavin.hu@arm.com, honnappa.nagarahalli@arm.com, phil.yang@arm.com, nd@arm.com Date: Fri, 29 Mar 2019 18:56:38 +0800 Message-Id: <1553856998-25394-4-git-send-email-phil.yang@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1553856998-25394-1-git-send-email-phil.yang@arm.com> References: <1553856998-25394-1-git-send-email-phil.yang@arm.com> In-Reply-To: <1546508946-12552-1-git-send-email-phil.yang@arm.com> References: <1546508946-12552-1-git-send-email-phil.yang@arm.com> Subject: [dpdk-dev] [PATCH v2 3/3] test/ring_perf: replace sync builtins with atomic builtins X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190329105638.QfstHVjLtCKXo1gia4O0bZa_0VLwSXw61RYrGjn7bNU@z> '__sync' built-in functions are deprecated, should use the '__atomic' built-in instead. the sync built-in functions are full barriers, while atomic built-in functions offer less restrictive one-way barriers, which help performance. Here is the example test result on TX2: sudo ./arm64-armv8a-linuxapp-gcc/app/test -c 0x7fffffe \ -n 4 --socket-mem=1024,0 --file-prefix=~ -- -i RTE>>ring_perf_autotest *** ring_perf_autotest without this patch *** SP/SC bulk enq/dequeue (size: 8): 6.22 MP/MC bulk enq/dequeue (size: 8): 11.50 SP/SC bulk enq/dequeue (size: 32): 1.85 MP/MC bulk enq/dequeue (size: 32): 2.66 *** ring_perf_autotest with this patch *** SP/SC bulk enq/dequeue (size: 8): 6.13 MP/MC bulk enq/dequeue (size: 8): 9.83 SP/SC bulk enq/dequeue (size: 32): 1.96 MP/MC bulk enq/dequeue (size: 32): 2.30 So for the ring performance test, this patch improved 11% of ring operations performance. Signed-off-by: Phil Yang Reviewed-by: Gavin Hu Reviewed-by: Joyce Kong Reviewed-by: Dharmik Thakkar --- app/test/test_ring_perf.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/test/test_ring_perf.c b/app/test/test_ring_perf.c index ebb3939..e851c1a 100644 --- a/app/test/test_ring_perf.c +++ b/app/test/test_ring_perf.c @@ -160,7 +160,11 @@ enqueue_bulk(void *p) unsigned i; void *burst[MAX_BURST] = {0}; - if ( __sync_add_and_fetch(&lcore_count, 1) != 2 ) +#ifdef RTE_USE_C11_MEM_MODEL + if (__atomic_add_fetch(&lcore_count, 1, __ATOMIC_RELAXED) != 2) +#else + if (__sync_add_and_fetch(&lcore_count, 1) != 2) +#endif while(lcore_count != 2) rte_pause(); @@ -196,7 +200,11 @@ dequeue_bulk(void *p) unsigned i; void *burst[MAX_BURST] = {0}; - if ( __sync_add_and_fetch(&lcore_count, 1) != 2 ) +#ifdef RTE_USE_C11_MEM_MODEL + if (__atomic_add_fetch(&lcore_count, 1, __ATOMIC_RELAXED) != 2) +#else + if (__sync_add_and_fetch(&lcore_count, 1) != 2) +#endif while(lcore_count != 2) rte_pause(); -- 2.7.4