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
This commit is contained in:
parent
4da47b2fec
commit
38c9c1708b
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user