提交 54988727 编写于 作者: W Will Deacon

locking/barriers: Use '__unqual_scalar_typeof' for load-acquire macros

Passing volatile-qualified pointers to the asm-generic implementations of
the load-acquire macros results in a re-load from the stack due to the
temporary result variable inheriting the volatile semantics thanks to the
use of 'typeof()'.

Define these temporary variables using 'unqual_scalar_typeof' to drop
the volatile qualifier in the case that they are scalar types.

Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: NWill Deacon <will@kernel.org>
上级 dee081bf
...@@ -128,10 +128,10 @@ do { \ ...@@ -128,10 +128,10 @@ do { \
#ifndef __smp_load_acquire #ifndef __smp_load_acquire
#define __smp_load_acquire(p) \ #define __smp_load_acquire(p) \
({ \ ({ \
typeof(*p) ___p1 = READ_ONCE(*p); \ __unqual_scalar_typeof(*p) ___p1 = READ_ONCE(*p); \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
__smp_mb(); \ __smp_mb(); \
___p1; \ (typeof(*p))___p1; \
}) })
#endif #endif
...@@ -183,10 +183,10 @@ do { \ ...@@ -183,10 +183,10 @@ do { \
#ifndef smp_load_acquire #ifndef smp_load_acquire
#define smp_load_acquire(p) \ #define smp_load_acquire(p) \
({ \ ({ \
typeof(*p) ___p1 = READ_ONCE(*p); \ __unqual_scalar_typeof(*p) ___p1 = READ_ONCE(*p); \
compiletime_assert_atomic_type(*p); \ compiletime_assert_atomic_type(*p); \
barrier(); \ barrier(); \
___p1; \ (typeof(*p))___p1; \
}) })
#endif #endif
...@@ -229,14 +229,14 @@ do { \ ...@@ -229,14 +229,14 @@ do { \
#ifndef smp_cond_load_relaxed #ifndef smp_cond_load_relaxed
#define smp_cond_load_relaxed(ptr, cond_expr) ({ \ #define smp_cond_load_relaxed(ptr, cond_expr) ({ \
typeof(ptr) __PTR = (ptr); \ typeof(ptr) __PTR = (ptr); \
typeof(*ptr) VAL; \ __unqual_scalar_typeof(*ptr) VAL; \
for (;;) { \ for (;;) { \
VAL = READ_ONCE(*__PTR); \ VAL = READ_ONCE(*__PTR); \
if (cond_expr) \ if (cond_expr) \
break; \ break; \
cpu_relax(); \ cpu_relax(); \
} \ } \
VAL; \ (typeof(*ptr))VAL; \
}) })
#endif #endif
...@@ -250,10 +250,10 @@ do { \ ...@@ -250,10 +250,10 @@ do { \
*/ */
#ifndef smp_cond_load_acquire #ifndef smp_cond_load_acquire
#define smp_cond_load_acquire(ptr, cond_expr) ({ \ #define smp_cond_load_acquire(ptr, cond_expr) ({ \
typeof(*ptr) _val; \ __unqual_scalar_typeof(*ptr) _val; \
_val = smp_cond_load_relaxed(ptr, cond_expr); \ _val = smp_cond_load_relaxed(ptr, cond_expr); \
smp_acquire__after_ctrl_dep(); \ smp_acquire__after_ctrl_dep(); \
_val; \ (typeof(*ptr))_val; \
}) })
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册