[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200901052154.45958.nickpiggin@yahoo.com.au>
Date: Mon, 5 Jan 2009 21:54:45 +1100
From: Nick Piggin <nickpiggin@...oo.com.au>
To: Alan Cox <alan@...rguk.ukuu.org.uk>
Cc: Pavel Machek <pavel@...e.cz>,
kernel list <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...l.org>, mtk.manpages@...il.com,
rdunlap@...otime.net, linux-doc@...r.kernel.org
Subject: Re: atomics: document that linux expects certain atomic behaviour from unsigned long
On Sunday 04 January 2009 10:14:19 Alan Cox wrote:
> > Is there concrete architecture where it breaks? I'd expect i386/x86-64
> > to be safe, and pretty much everyone to be safe as long as that long
> > is aligned.... or that was the result of arch-maintainers
> > discussion...
>
> It'll break on x86 if gcc decides to cache the value and you don't have
> explicit barriers.
Same as atomic_read on x86.
> If the long is not aligned it's not safe on x86 at all.
Same as atomic_t.
AFAIK, Linux requires aligned loads and stores to int and long (and pointer)
to be atomic.
Pretty much everywhere that uses RCU for example does so using atomic pointer
loads and stores. The nastiest issue IMO actually is reloading the value
through the pointer even if it isn't explicitly dereferenced. RCU gets this
right with ACCESS_ONCE. Probably a lot of code using basic types does not.
x86 atomic_read maybe should be using ACCESS_ONCE too...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists