test: remove unnecessary rte_srand
PATCH 1/1 test: remove unnecessary rte_srand
The random number is already initialized to a better random seed during starup process. The calls to rte_srand() are redundant and actually make entropy worse.
Signed-off-by Stephen Hemminger <[email protected]>
--- 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(-)
app/test/test_fib6_perf.c +0 -2
@@ -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,
app/test/test_fib_perf.c +0 -2
@@ -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 );
app/test/test_hash_multiwriter.c +0 -2
@@ -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 ) {
app/test/test_lpm6_perf.c +0 -2
@@ -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 );
app/test/test_lpm_perf.c +0 -2
@@ -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 );
app/test/test_malloc.c +0 -2
@@ -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;
app/test/test_memzone.c +0 -1
@@ -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 */
app/test/test_reciprocal_division.c +0 -1
@@ -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. */
app/test/test_reciprocal_division_perf.c +0 -2
@@ -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. */
Signature · 1 line
2.39.2
PATCH v2 1/1 test: remove unnecessary rte_srand
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 <[email protected]>
---
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(-)
app/test/test_fib6_perf.c +0 -2
@@ -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,
app/test/test_fib_perf.c +0 -2
@@ -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 );
app/test/test_hash_multiwriter.c +0 -2
@@ -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 ) {
app/test/test_lpm6_perf.c +0 -2
@@ -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 );
app/test/test_lpm_perf.c +0 -2
@@ -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 );
app/test/test_malloc.c +0 -2
@@ -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;
app/test/test_memzone.c +0 -1
@@ -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 */
app/test/test_reciprocal_division.c +0 -1
@@ -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. */
app/test/test_reciprocal_division_perf.c +0 -2
@@ -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. */
Signature · 1 line
2.39.2
Thomas Monjalon
Applied04/07/2023 01:21, Stephen Hemminger:
Quoted 5 lines
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 <[email protected]>
Applied, thanks.