* [PATCH] test: remove unnecessary rte_srand
@ 2023-07-03 18:49 Stephen Hemminger
2023-07-03 23:21 ` [PATCH v2] " Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2023-07-03 18:49 UTC (permalink / raw)
To: dev
Cc: Stephen Hemminger, Vladimir Medvedkin, Yipeng Wang,
Sameh Gobriel, Bruce Richardson, Anatoly Burakov
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 <stephen@networkplumber.org>
---
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(-)
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. */
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] test: remove unnecessary rte_srand
2023-07-03 18:49 [PATCH] test: remove unnecessary rte_srand Stephen Hemminger
@ 2023-07-03 23:21 ` Stephen Hemminger
2024-03-06 21:43 ` Thomas Monjalon
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2023-07-03 23:21 UTC (permalink / raw)
To: dev; +Cc: 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>
---
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(-)
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. */
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] test: remove unnecessary rte_srand
2023-07-03 23:21 ` [PATCH v2] " Stephen Hemminger
@ 2024-03-06 21:43 ` Thomas Monjalon
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2024-03-06 21:43 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-06 21:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-03 18:49 [PATCH] test: remove unnecessary rte_srand Stephen Hemminger
2023-07-03 23:21 ` [PATCH v2] " Stephen Hemminger
2024-03-06 21:43 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).