svn commit: r309143 - head/sys/libkern

Oleg Bulyzhin oleg at FreeBSD.org
Fri Nov 25 21:24:30 UTC 2016


On Fri, Nov 25, 2016 at 01:49:33PM +0000, Fabien Thomas wrote:

> +	if (reseed || atomic_cmpset_int(&arc4rand_iniseed_state,
> +			ARC4_ENTR_HAVE, ARC4_ENTR_SEED)) {
> +		ARC4_FOREACH(arc4)
> +			arc4_randomstir(arc4);
> +	}

How about eliminating this atomic? Converting it to:

if (reseed || arc4rand_iniseed_state == ARC4_ENTR_HAVE) {
	arc4rand_iniseed_state = ARC4_ENTR_SEED;
	ARC4_FOREACH(arc4);
		arc4_randomstir(arc4);
}
should give you free performance boost. Having locked cmpxchg in main path is
not cheap (and as i can see it's really used only once,
when randomdev unblocks).

P.S. quick and dirty test gives me 10-30% of extra perfomance.

-- 
Oleg.

================================================================
=== Oleg Bulyzhin -- OBUL-RIPN -- OBUL-RIPE -- oleg at rinet.ru ===
================================================================



More information about the svn-src-all mailing list