Re: [RFC PATCH 5/8] READ_ONCE: Enforce atomicity for {READ,WRITE}_ONCE() memory accesses

From
Will Deacon <will@kernel.org>
Date
2020-01-13 16:16:13
Also in
lkml
Reply to
Arnd Bergmann, 2020-01-10
On Fri, Jan 10, 2020 at 08:24:00PM +0100, Arnd Bergmann wrote:
On Fri, Jan 10, 2020 at 5:56 PM Will Deacon [off-list ref] wrote:
quoted
+/*
+ * Use __READ_ONCE() instead of READ_ONCE() if you do not require any
+ * atomicity or dependency ordering guarantees. Note that this may result
+ * in tears!
+ */
+#define __READ_ONCE(x) (*(volatile typeof(x) *)&(x))
+
This probably allows writing

       extern int i;
       __READ_ONCE(i) = 1;

and not get a warning for it. How about also casting to 'const'?
Well spotted! I'll fold that in.

Will
Thread (32 messages) 32 messages, 10 authors, last reply 2020-01-15
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help