tools: Upgrade atomic_set() to use WRITE_ONCE()
PATCH 1/1 tools: Upgrade atomic_set() to use WRITE_ONCE()
Since the atomic operation in the tools directory is from the kernel source [1]. And from the commit [2], atomic_set() is at least WRITE_ONCE() in the kernel source. atomic_{read,set}() should be symmetry with {READ, WRITE}_ONCE() [3]. To be synchronous with the source, atomic_set() should use WRITE_ONCE() rather than plain access.
[1] commit da6d8567512d ("tools include: Add basic atomic.h implementation from the kernel sources")
[2] commit 62e8a3258bda ("atomic, arch: Audit atomic_{read,set}()")
[3] commit 6aa7de059173 ("locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns to READ_ONCE()/WRITE_ONCE()")
Signed-off-by asas1asas200 <[email protected]>
Signed-off-by Chih-En Lin <[email protected]>
--- tools/arch/x86/include/asm/atomic.h | 2 +- tools/include/asm-generic/atomic-gcc.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/arch/x86/include/asm/atomic.h +1 -1
@@ -37,7 +37,7 @@ static inline int atomic_read(const atomic_t *v)*/ static inline void atomic_set (atomic_t *v,int i) { - v->counter = i; +WRITE_ONCE (v->counter, i); }/**
tools/include/asm-generic/atomic-gcc.h +1 -1
@@ -34,7 +34,7 @@ static inline int atomic_read(const atomic_t *v)*/ static inline void atomic_set (atomic_t *v,int i) { - v->counter = i; +WRITE_ONCE (v->counter, i); }/**
Signature · 1 line
2.25.1