mbox series

[v2,0/6] Pseudo-random number generation improvements

Message ID 20190516175510.27154-1-mattias.ronnblom@ericsson.com (mailing list archive)
Headers
Series Pseudo-random number generation improvements |

Message

Mattias Rönnblom May 16, 2019, 5:55 p.m. UTC
  Make DPDK pseudo-random number generation multi-thread safe, go faster
and produce better-quality pseudo-random numbers.

This patchset requires the yet-to-be-merged rdseed build detection
patch for rdseed support to be enabled.
http://patchwork.dpdk.org/patch/53404/

Thanks to Stephen Hemminger, Bruce Richardson, Keith Wiles and Neil
Horman for valuable feedback.

PATCH v2:
* Introduce the x86 rdseed machine instruction as a first fallback, in case
  getentropy() is unavailable
* Use meson to detect getentropy() and rdseed

PATCH v1:
* Added performance tests
* Added __experimental to rte_rand_max() declaration
* Introduced a PRNG section in the MAINTAINERS file
* Added missing <rte_memory.h> include
* Use getentropy() instead of rdtsc for seeding the internal LCG

RFC v3:
* Since rte_rand() and rte_srand() have been a part of the API since long,
  the experimental attribute was removed and the symbols were moved out
  of the experimental section of the version.map file.
* rte_rand_max() performance improvements:
  * Avoid repeated rte_lcore_id() calls.
  * Handle a power-of-2 upper bound as a special case.
* Added a Bugzilla reference to the rte_rand() MT safety bug.

RFC v2:
* Removed 32-bit version of rte_rand() and rte_rand_max().
* Switched from a four-sequence LFSR (producing a 32-bit number)
  to a five-sequence LFSR (producing a 64-bit number).
* Added a note on generator not being cryptographically secure.

Mattias Rönnblom (6):
  eal: replace libc-based random number generation with LFSR
  eal: add pseudo-random number generation performance test
  eal: improve entropy for initial PRNG seed
  eal: introduce random generator function with upper bound
  eal: add bounded PRNG performance tests
  eal: add PRNG to MAINTAINERS and release notes

 MAINTAINERS                                |   6 +
 app/test/Makefile                          |   1 +
 app/test/test_rand_perf.c                  |  92 +++++++++
 doc/guides/rel_notes/release_19_08.rst     |  13 ++
 lib/librte_eal/common/include/rte_random.h |  47 +++--
 lib/librte_eal/common/meson.build          |   1 +
 lib/librte_eal/common/rte_random.c         | 212 +++++++++++++++++++++
 lib/librte_eal/freebsd/eal/Makefile        |   1 +
 lib/librte_eal/freebsd/eal/eal.c           |   2 -
 lib/librte_eal/linux/eal/Makefile          |   1 +
 lib/librte_eal/linux/eal/eal.c             |   2 -
 lib/librte_eal/meson.build                 |   3 +
 lib/librte_eal/rte_eal_version.map         |   9 +
 13 files changed, 368 insertions(+), 22 deletions(-)
 create mode 100644 app/test/test_rand_perf.c
 create mode 100644 lib/librte_eal/common/rte_random.c
  

Comments

Bruce Richardson May 16, 2019, 8:35 p.m. UTC | #1
On Thu, May 16, 2019 at 07:55:04PM +0200, Mattias Rönnblom wrote:
> Make DPDK pseudo-random number generation multi-thread safe, go faster
> and produce better-quality pseudo-random numbers.
> 
> This patchset requires the yet-to-be-merged rdseed build detection
> patch for rdseed support to be enabled.
> http://patchwork.dpdk.org/patch/53404/
> 
> Thanks to Stephen Hemminger, Bruce Richardson, Keith Wiles and Neil
> Horman for valuable feedback.
> 
This looks a good improvement to have in DPDK.

Series-acked-by: Bruce Richardson <bruce.richardson@intel.com>