eal: replace libc-based random generation with LFSR
authorMattias Rönnblom <mattias.ronnblom@ericsson.com>
Fri, 28 Jun 2019 09:01:20 +0000 (11:01 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 28 Jun 2019 13:23:38 +0000 (15:23 +0200)
commit3f002f06961262667694171c20cb3443be6017c1
tree790e80db10a0683ca714cba828505e9642a5c22a
parent609e79841fcf981b0bc863f03985569397a49d53
eal: replace libc-based random generation with LFSR

This commit replaces rte_rand()'s use of lrand48() with a DPDK-native
combined Linear Feedback Shift Register (LFSR) (also known as
Tausworthe) pseudo-random number generator.

This generator is faster and produces better-quality random numbers
than the linear congruential generator (LCG) of lib's lrand48(). The
implementation, as opposed to lrand48(), is multi-thread safe in
regards to concurrent rte_rand() calls from different lcore threads.
A LCG is still used, but only to seed the five per-lcore LFSR
sequences.

In addition, this patch also addresses the issue of the legacy
implementation only producing 62 bits of pseudo randomness, while the
API requires all 64 bits to be random.

This pseudo-random number generator is not cryptographically secure -
just like lrand48().

Bugzilla ID: 114
Bugzilla ID: 276

Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
13 files changed:
MAINTAINERS
app/test/Makefile
app/test/meson.build
app/test/test_rand_perf.c [new file with mode: 0644]
doc/guides/rel_notes/release_19_08.rst
lib/librte_eal/common/include/rte_random.h
lib/librte_eal/common/meson.build
lib/librte_eal/common/rte_random.c [new file with mode: 0644]
lib/librte_eal/freebsd/eal/Makefile
lib/librte_eal/freebsd/eal/eal.c
lib/librte_eal/linux/eal/Makefile
lib/librte_eal/linux/eal/eal.c
lib/librte_eal/rte_eal_version.map