From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 04907A046B for ; Tue, 23 Jul 2019 03:02:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E60111BF82; Tue, 23 Jul 2019 03:02:45 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 2F97C1BF5A for ; Tue, 23 Jul 2019 03:02:45 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE2 (envelope-from yskoh@mellanox.com) with ESMTPS (AES256-SHA encrypted); 23 Jul 2019 04:02:44 +0300 Received: from scfae-sc-2.mti.labs.mlnx (scfae-sc-2.mti.labs.mlnx [10.101.0.96]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x6N11HfX026580; Tue, 23 Jul 2019 04:02:42 +0300 From: Yongseok Koh To: Gavin Hu Cc: Joyce Kong , Ruifeng Wang , Honnappa Nagarahalli , Nipun Gupta , Konstantin Ananyev , dpdk stable Date: Mon, 22 Jul 2019 18:00:14 -0700 Message-Id: <20190723010115.6446-47-yskoh@mellanox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190723010115.6446-1-yskoh@mellanox.com> References: <20190723010115.6446-1-yskoh@mellanox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'test/spinlock: amortize the cost of getting time' has been queued to LTS release 17.11.7 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 17.11.7 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objection by 07/27/19. So please shout if anyone has objection. 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. Yongseok --- >From 85be9f32ddebec7f4b692836e351c570474c2258 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 d15edf73ce..ea2f63b882 100644 --- a/test/test/test_spinlock.c +++ b/test/test/test_spinlock.c @@ -125,16 +125,16 @@ 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 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(); @@ -143,15 +143,15 @@ load_loop_fn(void *func_param) while (rte_atomic32_read(&synchro) == 0); begin = rte_get_timer_cycles(); - while (time_diff < hz * TIME_MS / 1000) { + while (lcount < MAX_LOOP) { if (use_lock) rte_spinlock_lock(&lk); lcount++; 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; } @@ -165,14 +165,16 @@ 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()); @@ -187,11 +189,12 @@ test_spinlock_perf(void) rte_eal_mp_wait_lcore(); 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.21.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2019-07-22 17:55:09.053735050 -0700 +++ 0047-test-spinlock-amortize-the-cost-of-getting-time.patch 2019-07-22 17:55:06.094471000 -0700 @@ -1,13 +1,14 @@ -From a52c5530d8d2b21c1ff4a5b12b40216fb6ee06f1 Mon Sep 17 00:00:00 2001 +From 85be9f32ddebec7f4b692836e351c570474c2258 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,14 +17,14 @@ 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 -index 6795195aee..6ac749597a 100644 ---- a/app/test/test_spinlock.c -+++ b/app/test/test_spinlock.c -@@ -96,16 +96,16 @@ test_spinlock_recursive_per_core(__attribute__((unused)) void *arg) +diff --git a/test/test/test_spinlock.c b/test/test/test_spinlock.c +index d15edf73ce..ea2f63b882 100644 +--- a/test/test/test_spinlock.c ++++ b/test/test/test_spinlock.c +@@ -125,16 +125,16 @@ test_spinlock_recursive_per_core(__attribute__((unused)) void *arg) } static rte_spinlock_t lk = RTE_SPINLOCK_INITIALIZER; @@ -43,7 +44,7 @@ const int use_lock = *(int*)func_param; const unsigned lcore = rte_lcore_id(); -@@ -114,15 +114,15 @@ load_loop_fn(void *func_param) +@@ -143,15 +143,15 @@ load_loop_fn(void *func_param) while (rte_atomic32_read(&synchro) == 0); begin = rte_get_timer_cycles(); @@ -62,7 +63,7 @@ return 0; } -@@ -136,14 +136,16 @@ test_spinlock_perf(void) +@@ -165,14 +165,16 @@ test_spinlock_perf(void) printf("\nTest with no lock on single core...\n"); load_loop_fn(&lock); @@ -83,7 +84,7 @@ printf("\nTest with lock on %u cores...\n", rte_lcore_count()); -@@ -158,11 +160,12 @@ test_spinlock_perf(void) +@@ -187,11 +189,12 @@ test_spinlock_perf(void) rte_eal_mp_wait_lcore(); RTE_LCORE_FOREACH(i) {