[dpdk-stable] patch 'test/spinlock: amortize the cost of getting time' has been queued to LTS release 18.11.2

Kevin Traynor ktraynor at redhat.com
Tue Apr 16 16:37:15 CEST 2019


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 <gavin.hu at arm.com>
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 <gavin.hu at arm.com>
Reviewed-by: Joyce Kong <joyce.kong at arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang at arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli at arm.com>
Acked-by: Nipun Gupta <nipun.gupta at nxp.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev at intel.com>
---
 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 <gavin.hu at arm.com>
 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 at dpdk.org
 
 Signed-off-by: Gavin Hu <gavin.hu at arm.com>
 Reviewed-by: Joyce Kong <joyce.kong at arm.com>
@@ -16,13 +17,13 @@
 Acked-by: Nipun Gupta <nipun.gupta at nxp.com>
 Acked-by: Konstantin Ananyev <konstantin.ananyev at intel.com>
 ---
- 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;


More information about the stable mailing list