[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140509091131.GL30445@twins.programming.kicks-ass.net>
Date: Fri, 9 May 2014 11:11:31 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Mikulas Patocka <mpatocka@...hat.com>
Cc: James Hogan <james.hogan@...tec.com>, linux-metag@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] metag: fix memory barriers
On Thu, May 08, 2014 at 03:51:37PM -0400, Mikulas Patocka wrote:
> 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@...hat.com>
> Cc: stable@...r.kernel.org
Acked-by: Peter Zijlstra <peterz@...radead.org>
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists