]> git.proxmox.com Git - mirror_zfs.git/commit - module/zfs/zil.c
Optimize small random numbers generation
authorAlexander Motin <mav@FreeBSD.org>
Tue, 22 Jun 2021 23:35:23 +0000 (19:35 -0400)
committerGitHub <noreply@github.com>
Tue, 22 Jun 2021 23:35:23 +0000 (17:35 -0600)
commit29274c9f6d7caa864d2c95cb797ca3cf32b4ef66
treebfbbeb3232ea78004c7da180789a6c1a6e328ab0
parentba91311561834774bc8fedfafb19ca1012c9dadd
Optimize small random numbers generation

In all places except two spa_get_random() is used for small values,
and the consumers do not require well seeded high quality values.
Switch those two exceptions directly to random_get_pseudo_bytes()
and optimize spa_get_random(), renaming it to random_in_range(),
since it is not related to SPA or ZFS in general.

On FreeBSD directly map random_in_range() to new prng32_bounded() KPI
added in FreeBSD 13.  On Linux and in user-space just reduce the type
used to uint32_t to avoid more expensive 64bit division.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored-By: iXsystems, Inc.
Closes #12183
16 files changed:
include/os/freebsd/spl/sys/random.h
include/os/linux/spl/sys/random.h
include/sys/spa.h
include/sys/zfs_context.h
module/os/linux/zfs/arc_os.c
module/zfs/metaslab.c
module/zfs/mmp.c
module/zfs/multilist.c
module/zfs/spa.c
module/zfs/spa_misc.c
module/zfs/space_map.c
module/zfs/vdev_indirect.c
module/zfs/vdev_mirror.c
module/zfs/zil.c
module/zfs/zio_compress.c
module/zfs/zio_inject.c