diff options
author | rwatson <rwatson@FreeBSD.org> | 2004-08-11 03:33:32 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2004-08-11 03:33:32 +0000 |
commit | ede585e9913c11eb2e881c64767dba9d549276eb (patch) | |
tree | 2c5637ba69f88f5b788543ee9c74630dc1381b42 /sys/dev/random | |
parent | fbbaea5f906ae98c3b2fe400a10aa7f73d292697 (diff) | |
download | FreeBSD-src-ede585e9913c11eb2e881c64767dba9d549276eb.zip FreeBSD-src-ede585e9913c11eb2e881c64767dba9d549276eb.tar.gz |
Perform a lockless read to test whether an entropy havesting fifo is
full, avoiding the cost of mutex operations if it is. We re-test
once the mutex is acquired to make sure it's still true before doing
the -modify-write part of the read-modify-write. Note that due to
the maximum fifo depth being pretty deep, this is unlikely to improve
harvesting performance yet.
Approved by: markm
Diffstat (limited to 'sys/dev/random')
-rw-r--r-- | sys/dev/random/randomdev_soft.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/dev/random/randomdev_soft.c b/sys/dev/random/randomdev_soft.c index c73e098..6f4851b 100644 --- a/sys/dev/random/randomdev_soft.c +++ b/sys/dev/random/randomdev_soft.c @@ -296,6 +296,10 @@ random_harvest_internal(u_int64_t somecounter, const void *entropy, { struct harvest *event; + /* Lockless read to avoid lock operations if fifo is full. */ + if (harvestfifo[origin].count >= RANDOM_FIFO_MAX) + return; + /* Lock the particular fifo */ mtx_lock_spin(&harvestfifo[origin].lock); |