From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, frode.nordahl@canonical.com,
mattias.ronnblom@ericsson.com, anatoly.burakov@intel.com,
stable@dpdk.org, "Tyler Retzlaff" <roretzla@linux.microsoft.com>,
"Bruce Richardson" <bruce.richardson@intel.com>,
"Dmitry Kozlyuk" <dmitry.kozliuk@gmail.com>,
"Stephen Hemminger" <stephen@networkplumber.org>,
"Chengwen Feng" <fengchengwen@huawei.com>,
"Morten Brørup" <mb@smartsharesystems.com>,
"Konstantin Ananyev" <konstantin.ananyev@huawei.com>
Subject: [PATCH v2 2/5] random: defer seeding to EAL init
Date: Tue, 17 Dec 2024 09:59:49 +0100 [thread overview]
Message-ID: <20241217085954.3310414-3-david.marchand@redhat.com> (raw)
In-Reply-To: <20241217085954.3310414-1-david.marchand@redhat.com>
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")
Cc: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
Reviewed-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
Changes since v1:
- updated commitlog,
---
lib/eal/common/eal_private.h | 6 ++++++
lib/eal/common/rte_random.c | 7 +++++--
lib/eal/freebsd/eal.c | 2 ++
lib/eal/linux/eal.c | 2 ++
lib/eal/windows/eal.c | 2 ++
5 files changed, 17 insertions(+), 2 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
@@ -702,6 +702,12 @@ eal_get_internal_configuration(void);
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..307c26bb7c 100644
--- a/lib/eal/common/rte_random.c
+++ b/lib/eal/common/rte_random.c
@@ -14,6 +14,8 @@
#include <rte_lcore_var.h>
#include <rte_random.h>
+#include "eal_private.h"
+
struct __rte_cache_aligned rte_rand_state {
uint64_t z1;
uint64_t z2;
@@ -22,7 +24,7 @@ struct __rte_cache_aligned rte_rand_state {
uint64_t z5;
};
-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 */
static struct rte_rand_state unregistered_rand_state;
@@ -228,7 +230,8 @@ __rte_random_initial_seed(void)
return rte_get_tsc_cycles();
}
-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
@@ -777,6 +777,8 @@ rte_eal_init(int argc, char **argv)
return -1;
}
+ eal_rand_init();
+
eal_check_mem_on_local_socket();
if (rte_thread_set_affinity_by_id(rte_thread_self(),
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
@@ -1173,6 +1173,8 @@ rte_eal_init(int argc, char **argv)
return -1;
}
+ eal_rand_init();
+
eal_check_mem_on_local_socket();
if (rte_thread_set_affinity_by_id(rte_thread_self(),
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
@@ -410,6 +410,8 @@ rte_eal_init(int argc, char **argv)
return -1;
}
+ eal_rand_init();
+
if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
rte_eal_init_alert("Cannot set affinity");
--
2.47.0
next prev parent reply other threads:[~2024-12-17 9:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20241205175754.1673888-1-david.marchand@redhat.com>
2024-12-05 17:57 ` [PATCH 1/3] " David Marchand
2024-12-06 11:09 ` Mattias Rönnblom
2024-12-16 9:38 ` Burakov, Anatoly
2024-12-05 17:57 ` [PATCH 2/3] power: defer lcore variable allocation David Marchand
2024-12-06 11:29 ` Mattias Rönnblom
2024-12-12 7:57 ` David Marchand
2024-12-13 6:58 ` Mattias Rönnblom
2024-12-16 10:02 ` David Marchand
2024-12-05 17:57 ` [PATCH 3/3] eal/x86: defer power intrinsics " David Marchand
2024-12-06 11:32 ` Mattias Rönnblom
[not found] ` <20241217085954.3310414-1-david.marchand@redhat.com>
2024-12-17 8:59 ` David Marchand [this message]
2024-12-18 16:35 ` [PATCH v2 2/5] random: defer seeding to EAL init Stephen Hemminger
2024-12-18 17:03 ` Mattias Rönnblom
2024-12-17 8:59 ` [PATCH v2 3/5] power: defer lcore variable allocation David Marchand
2024-12-18 11:17 ` Burakov, Anatoly
2024-12-17 8:59 ` [PATCH v2 5/5] eal/x86: defer power intrinsics " David Marchand
2024-12-18 11:17 ` Burakov, Anatoly
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241217085954.3310414-3-david.marchand@redhat.com \
--to=david.marchand@redhat.com \
--cc=anatoly.burakov@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=dmitry.kozliuk@gmail.com \
--cc=fengchengwen@huawei.com \
--cc=frode.nordahl@canonical.com \
--cc=konstantin.ananyev@huawei.com \
--cc=mattias.ronnblom@ericsson.com \
--cc=mb@smartsharesystems.com \
--cc=roretzla@linux.microsoft.com \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.org \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).