Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Jan 2012 18:38:20 +0400
From:      Andrey Chernov <ache@FreeBSD.ORG>
To:        John Baldwin <jhb@FreeBSD.ORG>
Cc:        svn-src-head@FreeBSD.ORG, David Schultz <das@FreeBSD.ORG>, src-committers@FreeBSD.ORG, Mark Murray <markm@FreeBSD.ORG>, svn-src-all@FreeBSD.ORG
Subject:   Re: svn commit: r230230 - head/sys/dev/random
Message-ID:  <20120126143819.GA88677@vniz.net>
In-Reply-To: <201201260839.07855.jhb@freebsd.org>
References:  <E1Rny2A-000C3x-O6@groundzero.grondar.org> <20120126030305.GA80493@vniz.net> <20120126033950.GA80737@vniz.net> <201201260839.07855.jhb@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120126143819.GA88677>