I've thought about this:- credit_entropy_bits(&input_pool, - min_t(int, fls(delta>>1), 11)); + nbits = min_t(int, fls(delta>>1), 11); + spin_lock_irqsave(&state->lock, flags); + state->nbits += nbits; + spin_unlock_irqrestore(&state->lock, flags); + credit_entropy_bits(&input_pool,nbits);
Couldn't state->nbits be an atomic_t? The locking looks like it might be a little expensive. Maybe they should be per-cpu? I have no idea about the frequencies here...
about atomic_t:
- atomic_t might be 2^24 as a maximum value (on SPARC arch). I've created VMWare test machine and left it without any special load for a day. Then I measured the value of produced entropy. The max number was about 30000. 2^24/30000 ~ 559 days without overflowing. I don't know if it suits for our purpose... that's why I rejected this approach.
about per-cpu variables:
- the function called with interrupts enable so if I use spinlock I must disable interrupts, am I right?
-- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ