patch 'random: defer seeding to EAL init' has been queued to stable release 24.11.2
Kevin Traynor
ktraynor at redhat.com
Thu Feb 13 10:58:28 CET 2025
Hi,
FYI, your patch has been queued to stable release 24.11.2
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 02/17/25. So please
shout if anyone has objections.
Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.
Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable
This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/e07b9b8acdbeba76f3db1057d327ff0b13f60201
Thanks.
Kevin
---
>From e07b9b8acdbeba76f3db1057d327ff0b13f60201 Mon Sep 17 00:00:00 2001
From: David Marchand <david.marchand at redhat.com>
Date: Mon, 10 Feb 2025 22:31:55 +0100
Subject: [PATCH] random: defer seeding to EAL init
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[ upstream commit 6b77657ef2e473309a3435cdf63b0f0cbb8328af ]
The RNG is documented as being seeded as part of EAL init.
Move the initialisation (seeding) helper out of a constructor and
call it explicitly from rte_eal_init() as it was done before commit
3f002f069612 ("eal: replace libc-based random generation with LFSR").
This also moves the unconditional lcore variable allocation out of a
constructor.
While at it, mark local symbol rand_state as static.
Fixes: 29c39cd3d54d ("random: keep PRNG state in lcore variable")
Signed-off-by: David Marchand <david.marchand at redhat.com>
Reviewed-by: Mattias Rönnblom <mattias.ronnblom at ericsson.com>
Acked-by: Anatoly Burakov <anatoly.burakov at intel.com>
Acked-by: Frode Nordahl <frode.nordahl at canonical.com>
---
lib/eal/common/eal_private.h | 6 ++++++
lib/eal/common/rte_random.c | 12 +++++++++---
lib/eal/freebsd/eal.c | 2 ++
lib/eal/linux/eal.c | 2 ++
lib/eal/windows/eal.c | 2 ++
5 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
index bb315dab04..a10db6a399 100644
--- a/lib/eal/common/eal_private.h
+++ b/lib/eal/common/eal_private.h
@@ -703,4 +703,10 @@ rte_usage_hook_t
eal_get_application_usage_hook(void);
+/**
+ * Initialise random subsystem.
+ */
+void
+eal_rand_init(void);
+
/**
* Instruct primary process that a secondary process wants to attach.
diff --git a/lib/eal/common/rte_random.c b/lib/eal/common/rte_random.c
index cf0756f26a..8e62578176 100644
--- a/lib/eal/common/rte_random.c
+++ b/lib/eal/common/rte_random.c
@@ -15,4 +15,6 @@
#include <rte_random.h>
+#include "eal_private.h"
+
struct __rte_cache_aligned rte_rand_state {
uint64_t z1;
@@ -23,5 +25,5 @@ struct __rte_cache_aligned rte_rand_state {
};
-RTE_LCORE_VAR_HANDLE(struct rte_rand_state, rand_state);
+static RTE_LCORE_VAR_HANDLE(struct rte_rand_state, rand_state);
/* instance to be shared by all unregistered non-EAL threads */
@@ -130,6 +132,9 @@ struct rte_rand_state *__rte_rand_get_state(void)
idx = rte_lcore_id();
- if (unlikely(idx == LCORE_ID_ANY))
+ if (unlikely(idx == LCORE_ID_ANY)) {
+ /* Make sure rte_*rand() was called after rte_eal_init(). */
+ RTE_ASSERT(rand_state != NULL);
return &unregistered_rand_state;
+ }
return RTE_LCORE_VAR(rand_state);
@@ -229,5 +234,6 @@ __rte_random_initial_seed(void)
}
-RTE_INIT(rte_rand_init)
+void
+eal_rand_init(void)
{
uint64_t seed;
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index a96bbf5836..d07cff8651 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -778,4 +778,6 @@ rte_eal_init(int argc, char **argv)
}
+ eal_rand_init();
+
eal_check_mem_on_local_socket();
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index a6220524a4..b1e63e37fc 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -1174,4 +1174,6 @@ rte_eal_init(int argc, char **argv)
}
+ eal_rand_init();
+
eal_check_mem_on_local_socket();
diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
index 5cdc053a02..5c7526f922 100644
--- a/lib/eal/windows/eal.c
+++ b/lib/eal/windows/eal.c
@@ -411,4 +411,6 @@ rte_eal_init(int argc, char **argv)
}
+ eal_rand_init();
+
if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
--
2.48.1
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2025-02-12 17:29:41.005463095 +0000
+++ 0061-random-defer-seeding-to-EAL-init.patch 2025-02-12 17:29:34.389946162 +0000
@@ -1 +1 @@
-From 6b77657ef2e473309a3435cdf63b0f0cbb8328af Mon Sep 17 00:00:00 2001
+From e07b9b8acdbeba76f3db1057d327ff0b13f60201 Mon Sep 17 00:00:00 2001
@@ -8,0 +9,2 @@
+[ upstream commit 6b77657ef2e473309a3435cdf63b0f0cbb8328af ]
+
@@ -21 +22,0 @@
-Cc: stable at dpdk.org
@@ -36 +37 @@
-index b2a80dbec8..04ba8ddb86 100644
+index bb315dab04..a10db6a399 100644
More information about the stable
mailing list