* [PATCH] x86: use WRITE_ONCE/READ_ONCE in smp_store_release/smp_load_acquire
@ 2015-08-01 16:45 Andrey Konovalov
2015-08-01 16:55 ` Borislav Petkov
2015-08-01 17:18 ` Peter Zijlstra
0 siblings, 2 replies; 3+ messages in thread
From: Andrey Konovalov @ 2015-08-01 16:45 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
David S. Miller, Peter Zijlstra, Alexander Duyck, Borislav Petkov,
linux-kernel
Cc: Andrey Konovalov, Dmitry Vyukov
Replace ACCESS_ONCE() macro in smp_store_release() and smp_load_acquire()
from arch/x86/include/asm/barrier.h with WRITE_ONCE() and READ_ONCE() since
ACCESS_ONCE does not work reliably on non-scalar types.
WRITE_ONCE() and READ_ONCE() were introduced in the commits 230fa253df63
("kernel: Provide READ_ONCE and ASSIGN_ONCE") and 43239cbe79fc ("kernel:
Change ASSIGN_ONCE(val, x) to WRITE_ONCE(x, val)").
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
arch/x86/include/asm/barrier.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
index e51a8f8..d2bcfbe 100644
--- a/arch/x86/include/asm/barrier.h
+++ b/arch/x86/include/asm/barrier.h
@@ -57,12 +57,12 @@
do { \
compiletime_assert_atomic_type(*p); \
smp_mb(); \
- ACCESS_ONCE(*p) = (v); \
+ WRITE_ONCE(*p, v); \
} while (0)
#define smp_load_acquire(p) \
({ \
- typeof(*p) ___p1 = ACCESS_ONCE(*p); \
+ typeof(*p) ___p1 = READ_ONCE(*p); \
compiletime_assert_atomic_type(*p); \
smp_mb(); \
___p1; \
@@ -74,12 +74,12 @@ do { \
do { \
compiletime_assert_atomic_type(*p); \
barrier(); \
- ACCESS_ONCE(*p) = (v); \
+ WRITE_ONCE(*p, v); \
} while (0)
#define smp_load_acquire(p) \
({ \
- typeof(*p) ___p1 = ACCESS_ONCE(*p); \
+ typeof(*p) ___p1 = READ_ONCE(*p); \
compiletime_assert_atomic_type(*p); \
barrier(); \
___p1; \
--
2.5.0.rc2.392.g76e840b
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] x86: use WRITE_ONCE/READ_ONCE in smp_store_release/smp_load_acquire
2015-08-01 16:45 [PATCH] x86: use WRITE_ONCE/READ_ONCE in smp_store_release/smp_load_acquire Andrey Konovalov
@ 2015-08-01 16:55 ` Borislav Petkov
2015-08-01 17:18 ` Peter Zijlstra
1 sibling, 0 replies; 3+ messages in thread
From: Borislav Petkov @ 2015-08-01 16:55 UTC (permalink / raw)
To: Andrey Konovalov
Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
David S. Miller, Peter Zijlstra, Alexander Duyck, linux-kernel,
Dmitry Vyukov, Christian Borntraeger, Paul E. McKenney,
Davidlohr Bueso
On Sat, Aug 01, 2015 at 06:45:34PM +0200, Andrey Konovalov wrote:
> Replace ACCESS_ONCE() macro in smp_store_release() and smp_load_acquire()
> from arch/x86/include/asm/barrier.h with WRITE_ONCE() and READ_ONCE() since
> ACCESS_ONCE does not work reliably on non-scalar types.
>
> WRITE_ONCE() and READ_ONCE() were introduced in the commits 230fa253df63
> ("kernel: Provide READ_ONCE and ASSIGN_ONCE") and 43239cbe79fc ("kernel:
> Change ASSIGN_ONCE(val, x) to WRITE_ONCE(x, val)").
You actually forgot to CC the author. Let me add some more people to CC,
in addition.
> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> ---
> arch/x86/include/asm/barrier.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
> index e51a8f8..d2bcfbe 100644
> --- a/arch/x86/include/asm/barrier.h
> +++ b/arch/x86/include/asm/barrier.h
> @@ -57,12 +57,12 @@
> do { \
> compiletime_assert_atomic_type(*p); \
> smp_mb(); \
> - ACCESS_ONCE(*p) = (v); \
> + WRITE_ONCE(*p, v); \
> } while (0)
>
> #define smp_load_acquire(p) \
> ({ \
> - typeof(*p) ___p1 = ACCESS_ONCE(*p); \
> + typeof(*p) ___p1 = READ_ONCE(*p); \
> compiletime_assert_atomic_type(*p); \
> smp_mb(); \
> ___p1; \
> @@ -74,12 +74,12 @@ do { \
> do { \
> compiletime_assert_atomic_type(*p); \
> barrier(); \
> - ACCESS_ONCE(*p) = (v); \
> + WRITE_ONCE(*p, v); \
> } while (0)
>
> #define smp_load_acquire(p) \
> ({ \
> - typeof(*p) ___p1 = ACCESS_ONCE(*p); \
> + typeof(*p) ___p1 = READ_ONCE(*p); \
> compiletime_assert_atomic_type(*p); \
> barrier(); \
> ___p1; \
> --
> 2.5.0.rc2.392.g76e840b
>
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] x86: use WRITE_ONCE/READ_ONCE in smp_store_release/smp_load_acquire
2015-08-01 16:45 [PATCH] x86: use WRITE_ONCE/READ_ONCE in smp_store_release/smp_load_acquire Andrey Konovalov
2015-08-01 16:55 ` Borislav Petkov
@ 2015-08-01 17:18 ` Peter Zijlstra
1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2015-08-01 17:18 UTC (permalink / raw)
To: Andrey Konovalov
Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
David S. Miller, Alexander Duyck, Borislav Petkov, linux-kernel,
Dmitry Vyukov
On Sat, Aug 01, 2015 at 06:45:34PM +0200, Andrey Konovalov wrote:
> Replace ACCESS_ONCE() macro in smp_store_release() and smp_load_acquire()
> from arch/x86/include/asm/barrier.h with WRITE_ONCE() and READ_ONCE() since
> ACCESS_ONCE does not work reliably on non-scalar types.
>
> WRITE_ONCE() and READ_ONCE() were introduced in the commits 230fa253df63
> ("kernel: Provide READ_ONCE and ASSIGN_ONCE") and 43239cbe79fc ("kernel:
> Change ASSIGN_ONCE(val, x) to WRITE_ONCE(x, val)").
Please do all relevant archs.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-08-01 17:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-01 16:45 [PATCH] x86: use WRITE_ONCE/READ_ONCE in smp_store_release/smp_load_acquire Andrey Konovalov
2015-08-01 16:55 ` Borislav Petkov
2015-08-01 17:18 ` Peter Zijlstra
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.