svn commit: r253786 - in head/sys: dev/random modules/padlock_rng modules/rdrand_rng modules/yarrow_rng

David O'Brien obrien at FreeBSD.org
Wed Jul 31 00:15:52 UTC 2013


On Tue, Jul 30, 2013 at 05:07:46PM -0700, David O'Brien (@FreeBSD) wrote:
> I believe you're talking about this code in
> sys/libkern/arc4random.c:arc4rand()
> 
> 	if (atomic_cmpset_int(&arc4rand_iniseed_state, ARC4_ENTR_HAVE,
> 	    ARC4_ENTR_SEED) || reseed ||
> 	   (arc4_numruns > ARC4_RESEED_BYTES) ||
> 	   (tv.tv_sec > arc4_t_reseed))
> 		arc4_randomstir();

Looking at this, seems to me that it would be more optimized if we tested
the things that are most likely to be TRUE first instead of those things
most likely to be FALSE?  ARC4_ENTR_HAVE->ARC4_ENTR_SEED can only happen
once per boot, and the 'reseed' flag is '0' in the majority of the
arc4rand() callers.

-- 
-- David    (obrien at FreeBSD.org)


More information about the svn-src-head mailing list