[v2] test: remove unnecessary rte_srand

Message ID 20230703232128.121849-1-stephen@networkplumber.org (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] test: remove unnecessary rte_srand |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-aarch-unit-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS

Commit Message

Stephen Hemminger July 3, 2023, 11:21 p.m. UTC
  The random number is already initialized to a better random
seed during startup process. The calls to rte_srand() are redundant
and actually make entropy worse.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
v2 - fix spelling error in commit message

 app/test/test_fib6_perf.c                | 2 --
 app/test/test_fib_perf.c                 | 2 --
 app/test/test_hash_multiwriter.c         | 2 --
 app/test/test_lpm6_perf.c                | 2 --
 app/test/test_lpm_perf.c                 | 2 --
 app/test/test_malloc.c                   | 2 --
 app/test/test_memzone.c                  | 1 -
 app/test/test_reciprocal_division.c      | 1 -
 app/test/test_reciprocal_division_perf.c | 2 --
 9 files changed, 16 deletions(-)
  

Comments

Thomas Monjalon March 6, 2024, 9:43 p.m. UTC | #1
04/07/2023 01:21, Stephen Hemminger:
> The random number is already initialized to a better random
> seed during startup process. The calls to rte_srand() are redundant
> and actually make entropy worse.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Applied, thanks.
  

Patch

diff --git a/app/test/test_fib6_perf.c b/app/test/test_fib6_perf.c
index add20c2331b1..f5c06b4fc9d0 100644
--- a/app/test/test_fib6_perf.c
+++ b/app/test/test_fib6_perf.c
@@ -83,8 +83,6 @@  test_fib6_perf(void)
 	conf.trie.nh_sz = RTE_FIB6_TRIE_4B;
 	conf.trie.num_tbl8 = RTE_MIN(get_max_nh(conf.trie.nh_sz), 1000000U);
 
-	rte_srand(rte_rdtsc());
-
 	printf("No. routes = %u\n", (unsigned int) NUM_ROUTE_ENTRIES);
 
 	print_route_distribution(large_route_table,
diff --git a/app/test/test_fib_perf.c b/app/test/test_fib_perf.c
index b56293e64f41..fcf8d222d90a 100644
--- a/app/test/test_fib_perf.c
+++ b/app/test/test_fib_perf.c
@@ -334,8 +334,6 @@  test_fib_perf(void)
 	int status = 0;
 	int64_t count = 0;
 
-	rte_srand(rte_rdtsc());
-
 	generate_large_route_rule_table();
 
 	printf("No. routes = %u\n", (unsigned int) NUM_ROUTE_ENTRIES);
diff --git a/app/test/test_hash_multiwriter.c b/app/test/test_hash_multiwriter.c
index 0c5a8ca18607..3b70157b433b 100644
--- a/app/test/test_hash_multiwriter.c
+++ b/app/test/test_hash_multiwriter.c
@@ -146,8 +146,6 @@  test_hash_multiwriter(void)
 		tbl_multiwriter_test_params.nb_tsx_insertion)
 		* tbl_multiwriter_test_params.nb_tsx_insertion;
 
-	rte_srand(rte_rdtsc());
-
 	keys = rte_malloc(NULL, sizeof(uint32_t) * nb_entries, 0);
 
 	if (keys == NULL) {
diff --git a/app/test/test_lpm6_perf.c b/app/test/test_lpm6_perf.c
index 5b684686a687..2e79655aa89c 100644
--- a/app/test/test_lpm6_perf.c
+++ b/app/test/test_lpm6_perf.c
@@ -66,8 +66,6 @@  test_lpm6_perf(void)
 	config.number_tbl8s = NUMBER_TBL8S;
 	config.flags = 0;
 
-	rte_srand(rte_rdtsc());
-
 	printf("No. routes = %u\n", (unsigned) NUM_ROUTE_ENTRIES);
 
 	print_route_distribution(large_route_table, (uint32_t) NUM_ROUTE_ENTRIES);
diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c
index e72437ba3850..dcc2eb375ae9 100644
--- a/app/test/test_lpm_perf.c
+++ b/app/test/test_lpm_perf.c
@@ -605,8 +605,6 @@  test_lpm_perf(void)
 	uint64_t cache_line_counter = 0;
 	int64_t count = 0;
 
-	rte_srand(rte_rdtsc());
-
 	generate_large_route_rule_table();
 
 	printf("No. routes = %u\n", (unsigned) NUM_ROUTE_ENTRIES);
diff --git a/app/test/test_malloc.c b/app/test/test_malloc.c
index ff081dd93139..b1d8be1e0491 100644
--- a/app/test/test_malloc.c
+++ b/app/test/test_malloc.c
@@ -692,8 +692,6 @@  test_random_alloc_free(void *_ __rte_unused)
 	unsigned i;
 	unsigned count = 0;
 
-	rte_srand((unsigned)rte_rdtsc());
-
 	for (i = 0; i < N; i++){
 		unsigned free_mem = 0;
 		size_t allocated_size;
diff --git a/app/test/test_memzone.c b/app/test/test_memzone.c
index f10f4fd9cd39..dd42f783c7ce 100644
--- a/app/test/test_memzone.c
+++ b/app/test/test_memzone.c
@@ -573,7 +573,6 @@  test_memzone_reserve_max_aligned(void)
 		socket = rte_socket_id_by_idx(i);
 
 		/* random alignment */
-		rte_srand((unsigned int)rte_rdtsc());
 		const unsigned int align = 1 << ((rte_rand() % 8) + 5); /* from 128 up to 4k alignment */
 
 		/* memzone size may be between size and size - align */
diff --git a/app/test/test_reciprocal_division.c b/app/test/test_reciprocal_division.c
index 8ea9b1d24d27..c70b90d2f4d7 100644
--- a/app/test/test_reciprocal_division.c
+++ b/app/test/test_reciprocal_division.c
@@ -32,7 +32,6 @@  test_reciprocal(void)
 	struct rte_reciprocal reci_u32 = {0};
 	struct rte_reciprocal_u64 reci_u64 = {0};
 
-	rte_srand(rte_rdtsc());
 	printf("Validating unsigned 32bit division.\n");
 	for (i = 0; i < MAX_ITERATIONS; i++) {
 		/* Change divisor every DIVIDE_ITER iterations. */
diff --git a/app/test/test_reciprocal_division_perf.c b/app/test/test_reciprocal_division_perf.c
index 4f625873e53a..3d25be71cae5 100644
--- a/app/test/test_reciprocal_division_perf.c
+++ b/app/test/test_reciprocal_division_perf.c
@@ -37,8 +37,6 @@  test_reciprocal_division_perf(void)
 	struct rte_reciprocal reci_u32 = {0};
 	struct rte_reciprocal_u64 reci_u64 = {0};
 
-	rte_srand(rte_rdtsc());
-
 	printf("Validating unsigned 32bit division.\n");
 	for (i = 0; i < MAX_ITERATIONS; i++) {
 		/* Change divisor every DIVIDE_ITER iterations. */