From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.101.70]) by dpdk.org (Postfix) with ESMTP id 5B7EA4C94 for ; Fri, 29 Mar 2019 11:56:55 +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 BDE4780D; Fri, 29 Mar 2019 03:56:54 -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 43EF33F575; Fri, 29 Mar 2019 03:56:53 -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:37 +0800 Message-Id: <1553856998-25394-3-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 2/3] test/distributor: 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:55 -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 -l 112-139 \ -n 4 --socket-mem=1024,1024 -- -i RTE>>distributor_perf_autotest *** distributor_perf_autotest without this patch *** ==== Cache line switch test === Time for 33554432 iterations = 1519202730 ticks Ticks per iteration = 45 *** distributor_perf_autotest with this patch *** ==== Cache line switch test === Time for 33554432 iterations = 1251715496 ticks Ticks per iteration = 37 Less ticks needed for the cache line switch test. It got 17% of performance improvement. Signed-off-by: Phil Yang Reviewed-by: Gavin Hu Reviewed-by: Ruifeng Wang Reviewed-by: Joyce Kong Reviewed-by: Dharmik Thakkar --- app/test/test_distributor.c | 18 +++++++++++++++++- app/test/test_distributor_perf.c | 7 ++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c index 98919ec..ddab08d 100644 --- a/app/test/test_distributor.c +++ b/app/test/test_distributor.c @@ -62,9 +62,14 @@ handle_work(void *arg) struct worker_params *wp = arg; struct rte_distributor *db = wp->dist; unsigned int count = 0, num = 0; - unsigned int id = __sync_fetch_and_add(&worker_idx, 1); int i; +#ifdef RTE_USE_C11_MEM_MODEL + unsigned int id = __atomic_fetch_add(&worker_idx, 1, __ATOMIC_RELAXED); +#else + unsigned int id = __sync_fetch_and_add(&worker_idx, 1); +#endif + for (i = 0; i < 8; i++) buf[i] = NULL; num = rte_distributor_get_pkt(db, id, buf, buf, num); @@ -270,7 +275,12 @@ handle_work_with_free_mbufs(void *arg) unsigned int count = 0; unsigned int i; unsigned int num = 0; + +#ifdef RTE_USE_C11_MEM_MODEL + unsigned int id = __atomic_fetch_add(&worker_idx, 1, __ATOMIC_RELAXED); +#else unsigned int id = __sync_fetch_and_add(&worker_idx, 1); +#endif for (i = 0; i < 8; i++) buf[i] = NULL; @@ -343,7 +353,13 @@ handle_work_for_shutdown_test(void *arg) unsigned int total = 0; unsigned int i; unsigned int returned = 0; + +#ifdef RTE_USE_C11_MEM_MODEL + const unsigned int id = __atomic_fetch_add(&worker_idx, 1, + __ATOMIC_RELAXED); +#else const unsigned int id = __sync_fetch_and_add(&worker_idx, 1); +#endif num = rte_distributor_get_pkt(d, id, buf, buf, num); diff --git a/app/test/test_distributor_perf.c b/app/test/test_distributor_perf.c index edf1998..9367460 100644 --- a/app/test/test_distributor_perf.c +++ b/app/test/test_distributor_perf.c @@ -111,9 +111,14 @@ handle_work(void *arg) unsigned int count = 0; unsigned int num = 0; int i; - unsigned int id = __sync_fetch_and_add(&worker_idx, 1); struct rte_mbuf *buf[8] __rte_cache_aligned; +#ifdef RTE_USE_C11_MEM_MODEL + unsigned int id = __atomic_fetch_add(&worker_idx, 1, __ATOMIC_RELAXED); +#else + unsigned int id = __sync_fetch_and_add(&worker_idx, 1); +#endif + for (i = 0; i < 8; i++) buf[i] = NULL; -- 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 E97F8A05D3 for ; Fri, 29 Mar 2019 11:57:06 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9D5274C9D; Fri, 29 Mar 2019 11:57:00 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.101.70]) by dpdk.org (Postfix) with ESMTP id 5B7EA4C94 for ; Fri, 29 Mar 2019 11:56:55 +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 BDE4780D; Fri, 29 Mar 2019 03:56:54 -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 43EF33F575; Fri, 29 Mar 2019 03:56:53 -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:37 +0800 Message-Id: <1553856998-25394-3-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 2/3] test/distributor: 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: <20190329105637.-EoY1slOJRgU540N6XTeubbbo7G9c284X8RHSuq1a88@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 -l 112-139 \ -n 4 --socket-mem=1024,1024 -- -i RTE>>distributor_perf_autotest *** distributor_perf_autotest without this patch *** ==== Cache line switch test === Time for 33554432 iterations = 1519202730 ticks Ticks per iteration = 45 *** distributor_perf_autotest with this patch *** ==== Cache line switch test === Time for 33554432 iterations = 1251715496 ticks Ticks per iteration = 37 Less ticks needed for the cache line switch test. It got 17% of performance improvement. Signed-off-by: Phil Yang Reviewed-by: Gavin Hu Reviewed-by: Ruifeng Wang Reviewed-by: Joyce Kong Reviewed-by: Dharmik Thakkar --- app/test/test_distributor.c | 18 +++++++++++++++++- app/test/test_distributor_perf.c | 7 ++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c index 98919ec..ddab08d 100644 --- a/app/test/test_distributor.c +++ b/app/test/test_distributor.c @@ -62,9 +62,14 @@ handle_work(void *arg) struct worker_params *wp = arg; struct rte_distributor *db = wp->dist; unsigned int count = 0, num = 0; - unsigned int id = __sync_fetch_and_add(&worker_idx, 1); int i; +#ifdef RTE_USE_C11_MEM_MODEL + unsigned int id = __atomic_fetch_add(&worker_idx, 1, __ATOMIC_RELAXED); +#else + unsigned int id = __sync_fetch_and_add(&worker_idx, 1); +#endif + for (i = 0; i < 8; i++) buf[i] = NULL; num = rte_distributor_get_pkt(db, id, buf, buf, num); @@ -270,7 +275,12 @@ handle_work_with_free_mbufs(void *arg) unsigned int count = 0; unsigned int i; unsigned int num = 0; + +#ifdef RTE_USE_C11_MEM_MODEL + unsigned int id = __atomic_fetch_add(&worker_idx, 1, __ATOMIC_RELAXED); +#else unsigned int id = __sync_fetch_and_add(&worker_idx, 1); +#endif for (i = 0; i < 8; i++) buf[i] = NULL; @@ -343,7 +353,13 @@ handle_work_for_shutdown_test(void *arg) unsigned int total = 0; unsigned int i; unsigned int returned = 0; + +#ifdef RTE_USE_C11_MEM_MODEL + const unsigned int id = __atomic_fetch_add(&worker_idx, 1, + __ATOMIC_RELAXED); +#else const unsigned int id = __sync_fetch_and_add(&worker_idx, 1); +#endif num = rte_distributor_get_pkt(d, id, buf, buf, num); diff --git a/app/test/test_distributor_perf.c b/app/test/test_distributor_perf.c index edf1998..9367460 100644 --- a/app/test/test_distributor_perf.c +++ b/app/test/test_distributor_perf.c @@ -111,9 +111,14 @@ handle_work(void *arg) unsigned int count = 0; unsigned int num = 0; int i; - unsigned int id = __sync_fetch_and_add(&worker_idx, 1); struct rte_mbuf *buf[8] __rte_cache_aligned; +#ifdef RTE_USE_C11_MEM_MODEL + unsigned int id = __atomic_fetch_add(&worker_idx, 1, __ATOMIC_RELAXED); +#else + unsigned int id = __sync_fetch_and_add(&worker_idx, 1); +#endif + for (i = 0; i < 8; i++) buf[i] = NULL; -- 2.7.4