[PATCH v1 1/1] eal/random: fix random state initialization for non-eal threads

Mattias Rönnblom hofors at lysator.liu.se
Mon Aug 28 14:22:51 CEST 2023


On 2023-08-28 14:06, Anatoly Burakov wrote:
> Currently, the rte_rand() state is initialized with seed, and each
> rand state is initialized up until RTE_MAX_LCORE'th rand state. However,
> rand state also has one extra rand state reserved for non-EAL threads,
> which is not initialized. Fix it by initializing this extra state.
> 
> Fixes: 3f002f069612 ("eal: replace libc-based random generation with LFSR")
> Cc: mattias.ronnblom at ericsson.com
> Cc: stable at dpdk.org
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
> ---
>   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 565f2401ce..e5691813a4 100644
> --- a/lib/eal/common/rte_random.c
> +++ b/lib/eal/common/rte_random.c
> @@ -83,7 +83,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_MAX_LCORE + 1; lcore_id++)
>   		__rte_srand_lfsr258(seed + lcore_id, &rand_states[lcore_id]);
>   }
>   

Acked-by: Mattias Rönnblom <mattias.ronnblom at ericsson.com>


More information about the stable mailing list