Date: Sat, 26 Nov 2016 00:17:20 +0300 From: Oleg Bulyzhin <oleg@FreeBSD.org> To: Fabien Thomas <fabient@FreeBSD.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r309143 - head/sys/libkern Message-ID: <20161125211720.GA66671@lath.rinet.ru> In-Reply-To: <201611251349.uAPDnX09042110@repo.freebsd.org> References: <201611251349.uAPDnX09042110@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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@rinet.ru ===
================================================================
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20161125211720.GA66671>
