From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8ABCA46211 for ; Thu, 13 Feb 2025 11:02:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8678E42EE9; Thu, 13 Feb 2025 11:02:07 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id E43F542EE7 for ; Thu, 13 Feb 2025 11:02:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739440926; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PU4gPD0Mgia2CeW0FNhr/C6Y9EWDJifX1akH4FfMbdM=; b=VFTTIYGg3q0eHawUDP0k0R8evdqHTsesgCLMBNt8UKJ+x5LHxAxQdBFJGSvPGTZukFz7S9 +s1SlPAo7vIGOzKSgS9DMY1DO9Rc6UwXF+0itdzX4qbYddQQ6OBDZTaWqDM7whaA5jqjX4 o7BYgSnCMnnFt4sZ68wDQh9zZMcz0Jg= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-197-_q-3O9U5NgO3K3VOOZ1NmQ-1; Thu, 13 Feb 2025 05:02:05 -0500 X-MC-Unique: _q-3O9U5NgO3K3VOOZ1NmQ-1 X-Mimecast-MFC-AGG-ID: _q-3O9U5NgO3K3VOOZ1NmQ_1739440924 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 55CDB1801A1D; Thu, 13 Feb 2025 10:02:04 +0000 (UTC) Received: from rh.Home (unknown [10.45.224.21]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1896B1800570; Thu, 13 Feb 2025 10:02:01 +0000 (UTC) From: Kevin Traynor To: David Marchand Cc: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= , Anatoly Burakov , Frode Nordahl , dpdk stable Subject: patch 'random: defer seeding to EAL init' has been queued to stable release 24.11.2 Date: Thu, 13 Feb 2025 09:58:28 +0000 Message-ID: <20250213095933.362078-61-ktraynor@redhat.com> In-Reply-To: <20250213095933.362078-1-ktraynor@redhat.com> References: <20250213095933.362078-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: zBgSsv26BvU-UtvuY_-lxqxmQVft9TOSPUomTJdDjeQ_1739440924 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org 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 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 Reviewed-by: Mattias Rönnblom Acked-by: Anatoly Burakov Acked-by: Frode Nordahl --- 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 +#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@dpdk.org @@ -36 +37 @@ -index b2a80dbec8..04ba8ddb86 100644 +index bb315dab04..a10db6a399 100644