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 1640A426A2; Mon, 2 Oct 2023 14:27:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AB45B40294; Mon, 2 Oct 2023 14:27:50 +0200 (CEST) Received: from mail.lysator.liu.se (mail.lysator.liu.se [130.236.254.3]) by mails.dpdk.org (Postfix) with ESMTP id B2CA84003C for ; Mon, 2 Oct 2023 14:27:49 +0200 (CEST) Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 5058E17D61 for ; Mon, 2 Oct 2023 14:27:49 +0200 (CEST) Received: by mail.lysator.liu.se (Postfix, from userid 1004) id 43E26181A4; Mon, 2 Oct 2023 14:27:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on hermod.lysator.liu.se X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=ALL_TRUSTED, AWL, NICE_REPLY_A autolearn=disabled version=3.4.6 X-Spam-Score: -2.7 Received: from [192.168.1.59] (h-62-63-215-114.A163.priv.bahnhof.se [62.63.215.114]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id D3B0117C6C; Mon, 2 Oct 2023 14:27:48 +0200 (CEST) Message-ID: <4a0cc5ff-a8e3-79cf-0190-09a4de2f1e9a@lysator.liu.se> Date: Mon, 2 Oct 2023 14:27:48 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v2 1/2] random: initialize the random state for non-EAL threads Content-Language: en-US To: Stephen Hemminger , dev@dpdk.org Cc: mattias.ronnblom@ericsson.com, =?UTF-8?Q?Morten_Br=c3=b8rup?= , Bruce Richardson References: <20230906155302.82749-1-stephen@networkplumber.org> <20230907152456.20570-1-stephen@networkplumber.org> <20230907152456.20570-2-stephen@networkplumber.org> From: =?UTF-8?Q?Mattias_R=c3=b6nnblom?= In-Reply-To: <20230907152456.20570-2-stephen@networkplumber.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 2023-09-07 17:24, Stephen Hemminger wrote: > 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 "/../ by an unregistered non-EAL thread /../" > 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 > Acked-by: Morten Brørup > Signed-off-by: Stephen Hemminger > --- > lib/eal/common/rte_random.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > 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]); > } > With the above-mentioned commit message rewording: Acked-by: Mattias Rönnblom