diff mbox series

[v5,1/4] test/lpm: fix cycle calculation in rcu qsbr perf

Message ID 20201104185858.18397-2-dharmik.thakkar@arm.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers show
Series test/lpm: fix rcu qsbr perf test | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Dharmik Thakkar Nov. 4, 2020, 6:58 p.m. UTC
Fix incorrect calculations for LPM adds, LPM deletes,
and average cycles in RCU QSBR perf tests

Since, rcu qsbr tests run for 'RCU_ITERATIONS' and not
'ITERATIONS', replace 'ITERATIONS' with 'RCU_ITERATIONS'
for calculating adds, deletes, and cycles.

Also, for multi-writer perf test, each writer only writes
half of NUM_LDEPTH_ROUTE_ENTRIES.
For 2 writers, total adds (or deletes) should be
(RCU_ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES) instead of
(2 * RCU_ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES).

Since, for both the single and multi writer tests, total adds/deletes
is equal to (RCU_ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES),
this has been replaced with a macro 'TOTAL_WRITES' and furthermore,
'g_writes' has been removed since it is always a fixed value
equal to TOTAL_WRITES.

Fixes: eff30b59cc2e ("test/lpm: add RCU performance tests")
Cc: honnappa.nagarahalli@arm.com
Cc: stable@dpdk.org

Signed-off-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
---
 app/test/test_lpm_perf.c | 45 ++++++++++++++--------------------------
 1 file changed, 16 insertions(+), 29 deletions(-)

Comments

Medvedkin, Vladimir Nov. 4, 2020, 7:34 p.m. UTC | #1
On 04/11/2020 18:58, Dharmik Thakkar wrote:
> Fix incorrect calculations for LPM adds, LPM deletes,
> and average cycles in RCU QSBR perf tests
> 
> Since, rcu qsbr tests run for 'RCU_ITERATIONS' and not
> 'ITERATIONS', replace 'ITERATIONS' with 'RCU_ITERATIONS'
> for calculating adds, deletes, and cycles.
> 
> Also, for multi-writer perf test, each writer only writes
> half of NUM_LDEPTH_ROUTE_ENTRIES.
> For 2 writers, total adds (or deletes) should be
> (RCU_ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES) instead of
> (2 * RCU_ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES).
> 
> Since, for both the single and multi writer tests, total adds/deletes
> is equal to (RCU_ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES),
> this has been replaced with a macro 'TOTAL_WRITES' and furthermore,
> 'g_writes' has been removed since it is always a fixed value
> equal to TOTAL_WRITES.
> 
> Fixes: eff30b59cc2e ("test/lpm: add RCU performance tests")
> Cc: honnappa.nagarahalli@arm.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> ---
>   app/test/test_lpm_perf.c | 45 ++++++++++++++--------------------------
>   1 file changed, 16 insertions(+), 29 deletions(-)
> 
> diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c
> index c5a238b9d1e8..45164b23214b 100644
> --- a/app/test/test_lpm_perf.c
> +++ b/app/test/test_lpm_perf.c
> @@ -23,7 +23,6 @@ static struct rte_rcu_qsbr *rv;
>   static volatile uint8_t writer_done;
>   static volatile uint32_t thr_id;
>   static uint64_t gwrite_cycles;
> -static uint64_t gwrites;
>   /* LPM APIs are not thread safe, use mutex to provide thread safety */
>   static pthread_mutex_t lpm_mutex = PTHREAD_MUTEX_INITIALIZER;
>   
> @@ -60,6 +59,8 @@ static uint32_t num_ldepth_route_entries;
>   #define NUM_ROUTE_ENTRIES num_route_entries
>   #define NUM_LDEPTH_ROUTE_ENTRIES num_ldepth_route_entries
>   
> +#define TOTAL_WRITES (RCU_ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES)
> +
>   enum {
>   	IP_CLASS_A,
>   	IP_CLASS_B,
> @@ -432,7 +433,6 @@ test_lpm_rcu_qsbr_writer(void *arg)
>   	uint8_t core_id = (uint8_t)((uintptr_t)arg);
>   	uint32_t next_hop_add = 0xAA;
>   
> -	RTE_SET_USED(arg);
>   	/* 2 writer threads are used */
>   	if (core_id % 2 == 0) {
>   		si = 0;
> @@ -472,9 +472,6 @@ test_lpm_rcu_qsbr_writer(void *arg)
>   	total_cycles = rte_rdtsc_precise() - begin;
>   
>   	__atomic_fetch_add(&gwrite_cycles, total_cycles, __ATOMIC_RELAXED);
> -	__atomic_fetch_add(&gwrites,
> -			2 * NUM_LDEPTH_ROUTE_ENTRIES * RCU_ITERATIONS,
> -			__ATOMIC_RELAXED);
>   
>   	return 0;
>   }
> @@ -528,7 +525,6 @@ test_lpm_rcu_perf_multi_writer(void)
>   
>   	writer_done = 0;
>   	__atomic_store_n(&gwrite_cycles, 0, __ATOMIC_RELAXED);
> -	__atomic_store_n(&gwrites, 0, __ATOMIC_RELAXED);
>   
>   	__atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST);
>   
> @@ -548,14 +544,11 @@ test_lpm_rcu_perf_multi_writer(void)
>   		if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0)
>   			goto error;
>   
> -	printf("Total LPM Adds: %d\n",
> -		2 * ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
> -	printf("Total LPM Deletes: %d\n",
> -		2 * ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
> +	printf("Total LPM Adds: %d\n", TOTAL_WRITES);
> +	printf("Total LPM Deletes: %d\n", TOTAL_WRITES);
>   	printf("Average LPM Add/Del: %"PRIu64" cycles\n",
> -		__atomic_load_n(&gwrite_cycles, __ATOMIC_RELAXED) /
> -			__atomic_load_n(&gwrites, __ATOMIC_RELAXED)
> -		);
> +		__atomic_load_n(&gwrite_cycles, __ATOMIC_RELAXED)
> +		/ TOTAL_WRITES);
>   
>   	/* Wait and check return value from reader threads */
>   	writer_done = 1;
> @@ -581,7 +574,6 @@ test_lpm_rcu_perf_multi_writer(void)
>   
>   	writer_done = 0;
>   	__atomic_store_n(&gwrite_cycles, 0, __ATOMIC_RELAXED);
> -	__atomic_store_n(&gwrites, 0, __ATOMIC_RELAXED);
>   	__atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST);
>   
>   	/* Launch reader threads */
> @@ -600,14 +592,11 @@ test_lpm_rcu_perf_multi_writer(void)
>   		if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0)
>   			goto error;
>   
> -	printf("Total LPM Adds: %d\n",
> -		2 * ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
> -	printf("Total LPM Deletes: %d\n",
> -		2 * ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
> +	printf("Total LPM Adds: %d\n", TOTAL_WRITES);
> +	printf("Total LPM Deletes: %d\n", TOTAL_WRITES);
>   	printf("Average LPM Add/Del: %"PRIu64" cycles\n",
> -		__atomic_load_n(&gwrite_cycles, __ATOMIC_RELAXED) /
> -			__atomic_load_n(&gwrites, __ATOMIC_RELAXED)
> -		);
> +		__atomic_load_n(&gwrite_cycles, __ATOMIC_RELAXED)
> +		/ TOTAL_WRITES);
>   
>   	writer_done = 1;
>   	/* Wait and check return value from reader threads */
> @@ -711,11 +700,10 @@ test_lpm_rcu_perf(void)
>   	}
>   	total_cycles = rte_rdtsc_precise() - begin;
>   
> -	printf("Total LPM Adds: %d\n", ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
> -	printf("Total LPM Deletes: %d\n",
> -		ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
> +	printf("Total LPM Adds: %d\n", TOTAL_WRITES);
> +	printf("Total LPM Deletes: %d\n", TOTAL_WRITES);
>   	printf("Average LPM Add/Del: %g cycles\n",
> -		(double)total_cycles / (NUM_LDEPTH_ROUTE_ENTRIES * ITERATIONS));
> +		(double)total_cycles / TOTAL_WRITES);
>   
>   	writer_done = 1;
>   	/* Wait and check return value from reader threads */
> @@ -771,11 +759,10 @@ test_lpm_rcu_perf(void)
>   	}
>   	total_cycles = rte_rdtsc_precise() - begin;
>   
> -	printf("Total LPM Adds: %d\n", ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
> -	printf("Total LPM Deletes: %d\n",
> -		ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
> +	printf("Total LPM Adds: %d\n", TOTAL_WRITES);
> +	printf("Total LPM Deletes: %d\n", TOTAL_WRITES);
>   	printf("Average LPM Add/Del: %g cycles\n",
> -		(double)total_cycles / (NUM_LDEPTH_ROUTE_ENTRIES * ITERATIONS));
> +		(double)total_cycles / TOTAL_WRITES);
>   
>   	writer_done = 1;
>   	/* Wait and check return value from reader threads */
> 

Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
diff mbox series

Patch

diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c
index c5a238b9d1e8..45164b23214b 100644
--- a/app/test/test_lpm_perf.c
+++ b/app/test/test_lpm_perf.c
@@ -23,7 +23,6 @@  static struct rte_rcu_qsbr *rv;
 static volatile uint8_t writer_done;
 static volatile uint32_t thr_id;
 static uint64_t gwrite_cycles;
-static uint64_t gwrites;
 /* LPM APIs are not thread safe, use mutex to provide thread safety */
 static pthread_mutex_t lpm_mutex = PTHREAD_MUTEX_INITIALIZER;
 
@@ -60,6 +59,8 @@  static uint32_t num_ldepth_route_entries;
 #define NUM_ROUTE_ENTRIES num_route_entries
 #define NUM_LDEPTH_ROUTE_ENTRIES num_ldepth_route_entries
 
+#define TOTAL_WRITES (RCU_ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES)
+
 enum {
 	IP_CLASS_A,
 	IP_CLASS_B,
@@ -432,7 +433,6 @@  test_lpm_rcu_qsbr_writer(void *arg)
 	uint8_t core_id = (uint8_t)((uintptr_t)arg);
 	uint32_t next_hop_add = 0xAA;
 
-	RTE_SET_USED(arg);
 	/* 2 writer threads are used */
 	if (core_id % 2 == 0) {
 		si = 0;
@@ -472,9 +472,6 @@  test_lpm_rcu_qsbr_writer(void *arg)
 	total_cycles = rte_rdtsc_precise() - begin;
 
 	__atomic_fetch_add(&gwrite_cycles, total_cycles, __ATOMIC_RELAXED);
-	__atomic_fetch_add(&gwrites,
-			2 * NUM_LDEPTH_ROUTE_ENTRIES * RCU_ITERATIONS,
-			__ATOMIC_RELAXED);
 
 	return 0;
 }
@@ -528,7 +525,6 @@  test_lpm_rcu_perf_multi_writer(void)
 
 	writer_done = 0;
 	__atomic_store_n(&gwrite_cycles, 0, __ATOMIC_RELAXED);
-	__atomic_store_n(&gwrites, 0, __ATOMIC_RELAXED);
 
 	__atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST);
 
@@ -548,14 +544,11 @@  test_lpm_rcu_perf_multi_writer(void)
 		if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0)
 			goto error;
 
-	printf("Total LPM Adds: %d\n",
-		2 * ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
-	printf("Total LPM Deletes: %d\n",
-		2 * ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
+	printf("Total LPM Adds: %d\n", TOTAL_WRITES);
+	printf("Total LPM Deletes: %d\n", TOTAL_WRITES);
 	printf("Average LPM Add/Del: %"PRIu64" cycles\n",
-		__atomic_load_n(&gwrite_cycles, __ATOMIC_RELAXED) /
-			__atomic_load_n(&gwrites, __ATOMIC_RELAXED)
-		);
+		__atomic_load_n(&gwrite_cycles, __ATOMIC_RELAXED)
+		/ TOTAL_WRITES);
 
 	/* Wait and check return value from reader threads */
 	writer_done = 1;
@@ -581,7 +574,6 @@  test_lpm_rcu_perf_multi_writer(void)
 
 	writer_done = 0;
 	__atomic_store_n(&gwrite_cycles, 0, __ATOMIC_RELAXED);
-	__atomic_store_n(&gwrites, 0, __ATOMIC_RELAXED);
 	__atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST);
 
 	/* Launch reader threads */
@@ -600,14 +592,11 @@  test_lpm_rcu_perf_multi_writer(void)
 		if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0)
 			goto error;
 
-	printf("Total LPM Adds: %d\n",
-		2 * ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
-	printf("Total LPM Deletes: %d\n",
-		2 * ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
+	printf("Total LPM Adds: %d\n", TOTAL_WRITES);
+	printf("Total LPM Deletes: %d\n", TOTAL_WRITES);
 	printf("Average LPM Add/Del: %"PRIu64" cycles\n",
-		__atomic_load_n(&gwrite_cycles, __ATOMIC_RELAXED) /
-			__atomic_load_n(&gwrites, __ATOMIC_RELAXED)
-		);
+		__atomic_load_n(&gwrite_cycles, __ATOMIC_RELAXED)
+		/ TOTAL_WRITES);
 
 	writer_done = 1;
 	/* Wait and check return value from reader threads */
@@ -711,11 +700,10 @@  test_lpm_rcu_perf(void)
 	}
 	total_cycles = rte_rdtsc_precise() - begin;
 
-	printf("Total LPM Adds: %d\n", ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
-	printf("Total LPM Deletes: %d\n",
-		ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
+	printf("Total LPM Adds: %d\n", TOTAL_WRITES);
+	printf("Total LPM Deletes: %d\n", TOTAL_WRITES);
 	printf("Average LPM Add/Del: %g cycles\n",
-		(double)total_cycles / (NUM_LDEPTH_ROUTE_ENTRIES * ITERATIONS));
+		(double)total_cycles / TOTAL_WRITES);
 
 	writer_done = 1;
 	/* Wait and check return value from reader threads */
@@ -771,11 +759,10 @@  test_lpm_rcu_perf(void)
 	}
 	total_cycles = rte_rdtsc_precise() - begin;
 
-	printf("Total LPM Adds: %d\n", ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
-	printf("Total LPM Deletes: %d\n",
-		ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
+	printf("Total LPM Adds: %d\n", TOTAL_WRITES);
+	printf("Total LPM Deletes: %d\n", TOTAL_WRITES);
 	printf("Average LPM Add/Del: %g cycles\n",
-		(double)total_cycles / (NUM_LDEPTH_ROUTE_ENTRIES * ITERATIONS));
+		(double)total_cycles / TOTAL_WRITES);
 
 	writer_done = 1;
 	/* Wait and check return value from reader threads */