Messages in this thread |  | | | Date | Wed, 1 Jul 2009 23:11:17 +0200 | | From | Ingo Molnar <> | | Subject | Re: [PATCH 1/2] FRV: Implement atomic64_t |
* Linus Torvalds <torvalds@linux-foundation.org> wrote:
> On Wed, 1 Jul 2009, David Howells wrote: > > + > > +#define ATOMIC64_INIT(i) { (i) } > > +#define atomic64_read(v) ((v)->counter) > > +#define atomic64_set(v, i) (((v)->counter) = (i)) > > These seem to be buggy. > > At least "atomic64_read()" needs to make sure to actually read it > atomically - otherwise you'll do two 32-bit reads, and that just > gets crap. Imagine if somebody is adding 1 to 0x00000000ffffffff, > and then "atomic64_read()" reads it as two accesses in the wrong > place, and gets either 0, or 0x00000001ffffffff, both of which are > totally incorrect. > > The case of 'atomic64_set()' is _slightly_ less clear, because I > think we use it mostly for initializers, so atomicity is often not > strictly required. But at least on x86, we do guarantee that it > sets it atomically too. > > Btw, Ingo: I looked at the x86-32 versions to be sure, and noticed > a couple of buglets:
thanks - we'll fix these!
Ingo
|  |