kernel: Provide READ_ONCE and ASSIGN_ONCE
authorChristian Borntraeger <borntraeger@de.ibm.com>
Tue, 25 Nov 2014 09:01:16 +0000 (10:01 +0100)
committerSasha Levin <sasha.levin@oracle.com>
Mon, 27 Apr 2015 03:02:56 +0000 (23:02 -0400)
commit63787890ec2624b97dd499050519781f346458b2
tree3c10f0e2a40be6edeb589bb79805e0cbc7848a5e
parentb94e91cc2225ea311e6bb8500f492702e319b348
kernel: Provide READ_ONCE and ASSIGN_ONCE

[ Upstream commit 230fa253df6352af12ad0a16128760b5cb3f92df ]

ACCESS_ONCE does not work reliably on non-scalar types. For
example gcc 4.6 and 4.7 might remove the volatile tag for such
accesses during the SRA (scalar replacement of aggregates) step
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145)

Let's provide READ_ONCE/ASSIGN_ONCE that will do all accesses via
scalar types as suggested by Linus Torvalds. Accesses larger than
the machines word size cannot be guaranteed to be atomic. These
macros will use memcpy and emit a build warning.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
include/linux/compiler.h