Date: Tue, 30 Jul 2013 17:15:51 -0700 From: "David O'Brien" <obrien@FreeBSD.org> To: Andrey Chernov <ache@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r253786 - in head/sys: dev/random modules/padlock_rng modules/rdrand_rng modules/yarrow_rng Message-ID: <20130731001551.GA67237@dragon.NUXI.org> In-Reply-To: <20130731000746.GA65806@dragon.NUXI.org> References: <201307292058.r6TKwA56031193@svn.freebsd.org> <51F6E0AB.3010001@freebsd.org> <20130731000746.GA65806@dragon.NUXI.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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@FreeBSD.org)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130731001551.GA67237>