Skip to content

Commit 44b97dc

Browse files
melverKAGA-KOKO
authored andcommitted
compiler.h: Remove data_race() and unnecessary checks from {READ,WRITE}_ONCE()
The volatile accesses no longer need to be wrapped in data_race() because compilers that emit instrumentation distinguishing volatile accesses are required for KCSAN. Consequently, the explicit kcsan_check_atomic*() are no longer required either since the compiler emits instrumentation distinguishing the volatile accesses. Finally, simplify __READ_ONCE_SCALAR() and remove __WRITE_ONCE_SCALAR(). [ bp: Convert commit message to passive voice. ] Signed-off-by: Marco Elver <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Will Deacon <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 0bb9ab3 commit 44b97dc

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

include/linux/compiler.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
281281

282282
#define __READ_ONCE_SCALAR(x) \
283283
({ \
284-
typeof(x) *__xp = &(x); \
285-
__unqual_scalar_typeof(x) __x = data_race(__READ_ONCE(*__xp)); \
286-
kcsan_check_atomic_read(__xp, sizeof(*__xp)); \
284+
__unqual_scalar_typeof(x) __x = __READ_ONCE(x); \
287285
smp_read_barrier_depends(); \
288286
(typeof(x))__x; \
289287
})
@@ -299,17 +297,10 @@ do { \
299297
*(volatile typeof(x) *)&(x) = (val); \
300298
} while (0)
301299

302-
#define __WRITE_ONCE_SCALAR(x, val) \
303-
do { \
304-
typeof(x) *__xp = &(x); \
305-
kcsan_check_atomic_write(__xp, sizeof(*__xp)); \
306-
data_race(({ __WRITE_ONCE(*__xp, val); 0; })); \
307-
} while (0)
308-
309300
#define WRITE_ONCE(x, val) \
310301
do { \
311302
compiletime_assert_rwonce_type(x); \
312-
__WRITE_ONCE_SCALAR(x, val); \
303+
__WRITE_ONCE(x, val); \
313304
} while (0)
314305

315306
#ifdef CONFIG_KASAN

0 commit comments

Comments
 (0)