From owner-svn-src-head@FreeBSD.ORG Thu Jan 26 13:44:25 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2F8DD106564A; Thu, 26 Jan 2012 13:44:25 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id F40228FC08; Thu, 26 Jan 2012 13:44:24 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) by cyrus.watson.org (Postfix) with ESMTPSA id A902546B0D; Thu, 26 Jan 2012 08:44:24 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 40AA6B93F; Thu, 26 Jan 2012 08:44:24 -0500 (EST) From: John Baldwin To: Andrey Chernov Date: Thu, 26 Jan 2012 08:39:07 -0500 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p10; KDE/4.5.5; amd64; ; ) References: <20120126030305.GA80493@vniz.net> <20120126033950.GA80737@vniz.net> In-Reply-To: <20120126033950.GA80737@vniz.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201201260839.07855.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 26 Jan 2012 08:44:24 -0500 (EST) 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-head@freebsd.org X-Mailman-Version: 2.1.5 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: Thu, 26 Jan 2012 13:44:25 -0000 On Wednesday, January 25, 2012 10:39:50 pm Andrey Chernov wrote: > On Thu, Jan 26, 2012 at 07:03:05AM +0400, Andrey Chernov wrote: > > On Wed, Jan 25, 2012 at 07:16:41PM +0000, Mark Murray wrote: > > > I thought you were going to do this as a function? It would be > > > slightly neater to do it that way. > > > > > > Looks good! Are you sure this needs no locking or volatile > > > variables? > > > > Now with function, volatile, atomic and even enum: > > Sorry. Reading of state variable should be atomical too. Fixed version: 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. Should you be using atomic_cmpset instead, e.g.: case ARC4_ENTER_HAVE: /* XXX: What does it mean for this to fail? */ atomic_cmpset_int(&iniseed_state, ARC4_ENTER_NONE, ARC4_ENTER_HAVE); break; -- John Baldwin