[dpdk-dev] [RFC] eal: make rte_rand() MT safe

Mattias Rönnblom mattias.ronnblom at ericsson.com
Fri Apr 5 15:51:39 CEST 2019


On 2019-04-05 15:45, Mattias Rönnblom wrote:
> The rte_rand() documentation left it unspecified if the rte_rand() was
> multi-thread safe or not, and the implementation (based on lrand48())
> was not.
> 
> This commit makes rte_rand() safe to use from any lcore thread by
> using lrand48_r() and per-lcore random state structs. Besides the
> obvious improvement in terms of correctness (for concurrent users),
> this also much improves rte_rand() performance, since the threads no
> longer shares state. For the single-threaded case, this patch causes
> ~10% rte_rand() performance degradation.
> 

It's a little unclear to me, if lrand48_r() exists in FreeBSD or not. 
Could someone confirm?

Another question I have is in which section of the version.map file the 
new symbols should go. Experimental, or 19.05?

The source interface is backward compatible, but the functions are no 
longer inline functions in the header file, and thus needs to go 
somewhere to be properly exported.


More information about the dev mailing list