Chris Friesen wrote:That would be a compiler bug. On most superscalar architectures, including powerpc, multiple instructions can be in flight simultaneously, potentially even reading and writing the same data. When the compiler detects data dependencies within a thread of execution, it will do the right thing. Putting the volatile keyword in here instructs the compiler to serialize accesses to this data even if it does not detect dependencies. It's worth noting that all of the SMP architectures which lack the volatile keyword in their atomic_t definition inherit memory access semantics from ISAs that predate the advent of heavily-pipelined superscalar design. i386 and x86_64 get theirs from at least as far back as the 8086. I believe s390(x) inherits this from the s/370 ISA. These ISAs assume strictly serialized memory access, and anything binary-compatible with them must enforce this in hardware, even at the expense of performance. Modern ISAs that lack legacy baggage do away with this guarantee, putting the burden on the compiler to enforce serialization. When the compiler can't detect that it's needed, we use volatile to inform it explicitly. -- Chris -
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| david | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Eric Paris | [RFC 0/5] [TALPA] Intro to a linux interface for on access scanning |
| Linus Torvalds | Linux 2.6.25-rc4 |
git: | |
| David Miller | [GIT]: Networking |
| Gerrit Renker | [PATCH 13/37] dccp: Deprecate Ack Ratio sysctl |
| Vladimir Ivashchenko | Re: HTB accuracy for high speed |
| Jarek Poplawski | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
