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 4D075A00E6 for ; Tue, 16 Apr 2019 16:39:16 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 408781B4D3; Tue, 16 Apr 2019 16:39:16 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 7E7411B4E3 for ; Tue, 16 Apr 2019 16:39:14 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF9C130ADBC4; Tue, 16 Apr 2019 14:39:13 +0000 (UTC) Received: from rh.redhat.com (ovpn-117-214.ams2.redhat.com [10.36.117.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC1971001DE0; Tue, 16 Apr 2019 14:39:11 +0000 (UTC) From: Kevin Traynor To: Gavin Hu Cc: Joyce Kong , Ruifeng Wang , Honnappa Nagarahalli , Nipun Gupta , Konstantin Ananyev , dpdk stable Date: Tue, 16 Apr 2019 15:37:15 +0100 Message-Id: <20190416143719.21601-57-ktraynor@redhat.com> In-Reply-To: <20190416143719.21601-1-ktraynor@redhat.com> References: <20190416143719.21601-1-ktraynor@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 16 Apr 2019 14:39:13 +0000 (UTC) Subject: [dpdk-stable] patch 'test/spinlock: amortize the cost of getting time' has been queued to LTS release 18.11.2 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to LTS release 18.11.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 04/24/19. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Kevin Traynor --- >From 779bd05e16dde88cbf9690e253b0fc51417c328a Mon Sep 17 00:00:00 2001 From: Gavin Hu Date: Fri, 8 Mar 2019 15:56:36 +0800 Subject: [PATCH] test/spinlock: amortize the cost of getting time [ upstream commit a52c5530d8d2b21c1ff4a5b12b40216fb6ee06f1 ] Instead of getting timestamps per iteration, amortize its overhead can help getting more precise benchmarking results. Fixes: af75078fece3 ("first public release") Signed-off-by: Gavin Hu Reviewed-by: Joyce Kong Reviewed-by: Ruifeng Wang Reviewed-by: Honnappa Nagarahalli Acked-by: Nipun Gupta Acked-by: Konstantin Ananyev --- test/test/test_spinlock.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/test/test/test_spinlock.c b/test/test/test_spinlock.c index 6795195ae..6ac749597 100644 --- a/test/test/test_spinlock.c +++ b/test/test/test_spinlock.c @@ -97,7 +97,7 @@ test_spinlock_recursive_per_core(__attribute__((unused)) void *arg) static rte_spinlock_t lk = RTE_SPINLOCK_INITIALIZER; -static uint64_t lock_count[RTE_MAX_LCORE] = {0}; +static uint64_t time_count[RTE_MAX_LCORE] = {0}; -#define TIME_MS 100 +#define MAX_LOOP 10000 static int @@ -106,5 +106,5 @@ load_loop_fn(void *func_param) uint64_t time_diff = 0, begin; uint64_t hz = rte_get_timer_hz(); - uint64_t lcount = 0; + volatile uint64_t lcount = 0; const int use_lock = *(int*)func_param; const unsigned lcore = rte_lcore_id(); @@ -115,5 +115,5 @@ load_loop_fn(void *func_param) begin = rte_get_timer_cycles(); - while (time_diff < hz * TIME_MS / 1000) { + while (lcount < MAX_LOOP) { if (use_lock) rte_spinlock_lock(&lk); @@ -121,7 +121,7 @@ load_loop_fn(void *func_param) if (use_lock) rte_spinlock_unlock(&lk); - time_diff = rte_get_timer_cycles() - begin; } - lock_count[lcore] = lcount; + time_diff = rte_get_timer_cycles() - begin; + time_count[lcore] = time_diff * 1000000 / hz; return 0; } @@ -137,12 +137,14 @@ test_spinlock_perf(void) printf("\nTest with no lock on single core...\n"); load_loop_fn(&lock); - printf("Core [%u] count = %"PRIu64"\n", lcore, lock_count[lcore]); - memset(lock_count, 0, sizeof(lock_count)); + printf("Core [%u] Cost Time = %"PRIu64" us\n", lcore, + time_count[lcore]); + memset(time_count, 0, sizeof(time_count)); printf("\nTest with lock on single core...\n"); lock = 1; load_loop_fn(&lock); - printf("Core [%u] count = %"PRIu64"\n", lcore, lock_count[lcore]); - memset(lock_count, 0, sizeof(lock_count)); + printf("Core [%u] Cost Time = %"PRIu64" us\n", lcore, + time_count[lcore]); + memset(time_count, 0, sizeof(time_count)); printf("\nTest with lock on %u cores...\n", rte_lcore_count()); @@ -159,9 +161,10 @@ test_spinlock_perf(void) RTE_LCORE_FOREACH(i) { - printf("Core [%u] count = %"PRIu64"\n", i, lock_count[i]); - total += lock_count[i]; + printf("Core [%u] Cost Time = %"PRIu64" us\n", i, + time_count[i]); + total += time_count[i]; } - printf("Total count = %"PRIu64"\n", total); + printf("Total Cost Time = %"PRIu64" us\n", total); return 0; -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2019-04-16 15:34:27.735335751 +0100 +++ 0057-test-spinlock-amortize-the-cost-of-getting-time.patch 2019-04-16 15:34:25.235178729 +0100 @@ -1,13 +1,14 @@ -From a52c5530d8d2b21c1ff4a5b12b40216fb6ee06f1 Mon Sep 17 00:00:00 2001 +From 779bd05e16dde88cbf9690e253b0fc51417c328a Mon Sep 17 00:00:00 2001 From: Gavin Hu Date: Fri, 8 Mar 2019 15:56:36 +0800 Subject: [PATCH] test/spinlock: amortize the cost of getting time +[ upstream commit a52c5530d8d2b21c1ff4a5b12b40216fb6ee06f1 ] + Instead of getting timestamps per iteration, amortize its overhead can help getting more precise benchmarking results. Fixes: af75078fece3 ("first public release") -Cc: stable@dpdk.org Signed-off-by: Gavin Hu Reviewed-by: Joyce Kong @@ -16,13 +17,13 @@ Acked-by: Nipun Gupta Acked-by: Konstantin Ananyev --- - app/test/test_spinlock.c | 29 ++++++++++++++++------------- + test/test/test_spinlock.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) -diff --git a/app/test/test_spinlock.c b/app/test/test_spinlock.c +diff --git a/test/test/test_spinlock.c b/test/test/test_spinlock.c index 6795195ae..6ac749597 100644 ---- a/app/test/test_spinlock.c -+++ b/app/test/test_spinlock.c +--- a/test/test/test_spinlock.c ++++ b/test/test/test_spinlock.c @@ -97,7 +97,7 @@ test_spinlock_recursive_per_core(__attribute__((unused)) void *arg) static rte_spinlock_t lk = RTE_SPINLOCK_INITIALIZER;