From owner-svn-src-all@FreeBSD.ORG Thu Jan 26 14:38:22 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D796D106564A; Thu, 26 Jan 2012 14:38:22 +0000 (UTC) (envelope-from ache@vniz.net) Received: from vniz.net (vniz.net [194.87.13.69]) by mx1.freebsd.org (Postfix) with ESMTP id 3F06E8FC1D; Thu, 26 Jan 2012 14:38:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by vniz.net (8.14.5/8.14.5) with ESMTP id q0QEcKpx091676; Thu, 26 Jan 2012 18:38:20 +0400 (MSK) (envelope-from ache@vniz.net) Received: (from ache@localhost) by localhost (8.14.5/8.14.5/Submit) id q0QEcKZs091675; Thu, 26 Jan 2012 18:38:20 +0400 (MSK) (envelope-from ache) Date: Thu, 26 Jan 2012 18:38:20 +0400 From: Andrey Chernov To: John Baldwin Message-ID: <20120126143819.GA88677@vniz.net> Mail-Followup-To: Andrey Chernov , John Baldwin , Mark Murray , David Schultz , src-committers@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, svn-src-head@FreeBSD.ORG References: <20120126030305.GA80493@vniz.net> <20120126033950.GA80737@vniz.net> <201201260839.07855.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201201260839.07855.jhb@freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@FreeBSD.ORG, David Schultz , src-committers@FreeBSD.ORG, Mark Murray , svn-src-all@FreeBSD.ORG Subject: Re: svn commit: r230230 - head/sys/dev/random X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Jan 2012 14:38:22 -0000 On Thu, Jan 26, 2012 at 08:39:07AM -0500, John Baldwin wrote: > What is the purpose of the atomics? Doing atomic_load/atomic_store > is just as racy as if you had not used atomics at all. Thanx for a hint. Protecting comparison itself isn't essential as protecting variable consitency because random_yarrow_unblock() which triggers operation isn't called concurrently, but arc4rand() is. I consider your suggested way a bit later. Yes, it seems acq/rel memory barriers are unneded, > Should you be > using atomic_cmpset instead, e.g.: > > case ARC4_ENTER_HAVE: > /* XXX: What does it mean for this to fail? */ It means "Request to have enough entropy, but already have or even already reseed". > atomic_cmpset_int(&iniseed_state, ARC4_ENTER_NONE, ARC4_ENTER_HAVE); > break; -- http://ache.vniz.net/