diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2014-05-08 15:51:37 -0400 |
---|---|---|
committer | Jiri Slaby <jslaby@suse.cz> | 2014-06-09 15:53:40 +0200 |
commit | 02f7ba733eca7c2dfce111ebff4558de51d5ce15 (patch) | |
tree | cc94df65b707d1d4b51f5ab90eb1f58b6ee163bd /samples/hw_breakpoint | |
parent | 50366435d4c0eee0b76fe4d04fd5f5d15a6a7c90 (diff) |
metag: fix memory barriers
commit 2425ce84026c385b73ae72039f90d042d49e0394 upstream.
Volatile access doesn't really imply the compiler barrier. Volatile access
is only ordered with respect to other volatile accesses, it isn't ordered
with respect to general memory accesses. Gcc may reorder memory accesses
around volatile access, as we can see in this simple example (if we
compile it with optimization, both increments of *b will be collapsed to
just one):
void fn(volatile int *a, long *b)
{
(*b)++;
*a = 10;
(*b)++;
}
Consequently, we need the compiler barrier after a write to the volatile
variable, to make sure that the compiler doesn't reorder the volatile
write with something else.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Diffstat (limited to 'samples/hw_breakpoint')
0 files changed, 0 insertions, 0 deletions