From owner-svn-src-head@FreeBSD.ORG Wed Jul 31 00:15:52 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 8A189FD5; Wed, 31 Jul 2013 00:15:52 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 71FFF2122; Wed, 31 Jul 2013 00:15:52 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id r6V0FqRA021379; Wed, 31 Jul 2013 00:15:52 GMT (envelope-from obrien@freefall.freebsd.org) Received: (from obrien@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id r6V0Fq1C021376; Wed, 31 Jul 2013 00:15:52 GMT (envelope-from obrien) Date: Tue, 30 Jul 2013 17:15:51 -0700 From: "David O'Brien" To: Andrey Chernov 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> References: <201307292058.r6TKwA56031193@svn.freebsd.org> <51F6E0AB.3010001@freebsd.org> <20130731000746.GA65806@dragon.NUXI.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130731000746.GA65806@dragon.NUXI.org> X-Operating-System: FreeBSD 10.0-CURRENT X-MUA-Host: dragon.NUXI.org X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? User-Agent: Mutt/1.5.20 (2009-06-14) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: obrien@freebsd.org List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Jul 2013 00:15:52 -0000 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)