DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] random: initialize the random state for non-eal lcores
@ 2023-09-06 15:53 Stephen Hemminger
  2023-09-06 16:25 ` Morten Brørup
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Stephen Hemminger @ 2023-09-06 15:53 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, mattias.ronnblom, Matan Azrad,
	Viacheslav Ovsiienko, Ori Kam, Suanming Mou, Bruce Richardson

The per-lcore PRNG was not initializing the rand_state of all
the lcores. Any usage of rte_random by a non-EAL lcore would
use rand_states[RTE_MAX_LCORE] which was never initialized.

Fix by using RTE_DIM() which will get all lcores.

Fixes: 3f002f069612 ("eal: replace libc-based random generation with LFSR")
Cc: mattias.ronnblom@ericsson.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/common/mlx5/linux/mlx5_common_os.c | 2 +-
 lib/eal/common/rte_random.c                | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c
index 2ebb8ac8b6e5..7260c1a19fd3 100644
--- a/drivers/common/mlx5/linux/mlx5_common_os.c
+++ b/drivers/common/mlx5/linux/mlx5_common_os.c
@@ -266,7 +266,7 @@ mlx5_glue_path(char *buf, size_t size)
 		goto error;
 	return buf;
 error:
-	RTE_LOG(ERR, PMD, "unable to append \"-glue\" to last component of"
+	DRV_LOG(ERR, "unable to append \"-glue\" to last component of"
 		" RTE_EAL_PMD_PATH (\"" RTE_EAL_PMD_PATH "\"), please"
 		" re-configure DPDK");
 	return NULL;
diff --git a/lib/eal/common/rte_random.c b/lib/eal/common/rte_random.c
index 53636331a27b..812e5b4757b5 100644
--- a/lib/eal/common/rte_random.c
+++ b/lib/eal/common/rte_random.c
@@ -84,7 +84,7 @@ rte_srand(uint64_t seed)
 	unsigned int lcore_id;
 
 	/* add lcore_id to seed to avoid having the same sequence */
-	for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++)
+	for (lcore_id = 0; lcore_id < RTE_DIM(rand_states); lcore_id++)
 		__rte_srand_lfsr258(seed + lcore_id, &rand_states[lcore_id]);
 }
 
-- 
2.39.2


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-10-04  8:45 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-06 15:53 [PATCH] random: initialize the random state for non-eal lcores Stephen Hemminger
2023-09-06 16:25 ` Morten Brørup
2023-09-06 16:28 ` Stephen Hemminger
2023-09-07 15:24 ` [PATCH v2 0/2] fixes to rte_random for non-EAL threads Stephen Hemminger
2023-09-07 15:24   ` [PATCH v2 1/2] random: initialize the random state " Stephen Hemminger
2023-10-02  9:00     ` Morten Brørup
2023-10-02 12:27     ` Mattias Rönnblom
2023-10-02 16:07       ` Stephen Hemminger
2023-10-04  8:45       ` David Marchand
2023-09-07 15:24   ` [PATCH v2 2/2] random: make rte_rand() thread safe " Stephen Hemminger
2023-09-07 15:47     ` Stephen Hemminger
2023-09-07 16:10       ` David Marchand
2023-09-08 20:48     ` Mattias Rönnblom
2023-09-08 20:56       ` Stephen Hemminger
2023-09-09  7:00         ` Mattias Rönnblom
2023-10-02 16:10     ` Stephen Hemminger

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).