From owner-svn-src-head@freebsd.org Fri Nov 25 21:24:30 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 08DD3C55BC9; Fri, 25 Nov 2016 21:24:30 +0000 (UTC) (envelope-from oleg@lath.rinet.ru) Received: from lath.rinet.ru (lath.rinet.ru [195.54.192.90]) by mx1.freebsd.org (Postfix) with ESMTP id BA7F4DB; Fri, 25 Nov 2016 21:24:29 +0000 (UTC) (envelope-from oleg@lath.rinet.ru) Received: by lath.rinet.ru (Postfix, from userid 222) id D6913ECA; Sat, 26 Nov 2016 00:17:20 +0300 (MSK) Date: Sat, 26 Nov 2016 00:17:20 +0300 From: Oleg Bulyzhin To: Fabien Thomas 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> References: <201611251349.uAPDnX09042110@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201611251349.uAPDnX09042110@repo.freebsd.org> User-Agent: Mutt/1.7.1 (2016-10-04) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list 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: Fri, 25 Nov 2016 21:24:30 -0000 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 === ================================================================