Memory corruption due to word sharing
Linus Torvalds
torvalds@linux-foundation.org
Wed Feb 1 23:11:00 GMT 2012
On Wed, Feb 1, 2012 at 2:45 PM, Paul E. McKenney
<paulmck@linux.vnet.ibm.com> wrote:
>
> My (perhaps forlorn and naive) hope is that C++11 memory_order_relaxed
> will eventually allow ACCESS_ONCE() to be upgraded so that (for example)
> access-once increments can generate a single increment-memory instruction
> on x86.
I don't think that is a semantic issue.
gcc could do it *today* with volatile accesses. It doesn't, because
volatiles are scary and basically disables a lot of optimizations. Why
would memory ordering be substantially different just because it has a
different name?
> New architectures might eventually might define things like atomic_inc()
> in terms of C++11 atomics, but let's start with the straightforward stuff
> as and if it makes sense.
SMP-atomic or percpu atomic? Or both?
We need both variants in the kernel. If the compiler generates one of
them for us, that doesn't really much help.
Linus
More information about the Gcc
mailing list