Skip to content

Commit 488beef

Browse files
committed
arm/spinlock: Replace ACCESS_ONCE with READ_ONCE
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) Change the spinlock code to replace ACCESS_ONCE with READ_ONCE. Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
1 parent af2e7aa commit 488beef

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/arm/include/asm/spinlock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ static inline int arch_spin_value_unlocked(arch_spinlock_t lock)
120120

121121
static inline int arch_spin_is_locked(arch_spinlock_t *lock)
122122
{
123-
return !arch_spin_value_unlocked(ACCESS_ONCE(*lock));
123+
return !arch_spin_value_unlocked(READ_ONCE(*lock));
124124
}
125125

126126
static inline int arch_spin_is_contended(arch_spinlock_t *lock)
127127
{
128-
struct __raw_tickets tickets = ACCESS_ONCE(lock->tickets);
128+
struct __raw_tickets tickets = READ_ONCE(lock->tickets);
129129
return (tickets.next - tickets.owner) > 1;
130130
}
131131
#define arch_spin_is_contended arch_spin_is_contended

0 commit comments

Comments
 (0)