linux/kernel/kcsan
Marco Elver 31f605a308 kcsan, compiler_types: Introduce __data_racy type qualifier
Based on the discussion at [1], it would be helpful to mark certain
variables as explicitly "data racy", which would result in KCSAN not
reporting data races involving any accesses on such variables. To do
that, introduce the __data_racy type qualifier:

	struct foo {
		...
		int __data_racy bar;
		...
	};

In KCSAN-kernels, __data_racy turns into volatile, which KCSAN already
treats specially by considering them "marked". In non-KCSAN kernels the
type qualifier turns into no-op.

The generated code between KCSAN-instrumented kernels and non-KCSAN
kernels is already huge (inserted calls into runtime for every memory
access), so the extra generated code (if any) due to volatile for few
such __data_racy variables are unlikely to have measurable impact on
performance.

Link: https://lore.kernel.org/all/CAHk-=wi3iondeh_9V2g3Qz5oHTRjLsOpoy83hb58MVh=nRZe0A@mail.gmail.com/ [1]
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Marco Elver <elver@google.com>
Cc: Paul E. McKenney <paulmck@kernel.org>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
2024-05-07 11:39:50 -07:00
..
.kunitconfig kcsan: test: Add a .kunitconfig to run KCSAN tests 2022-07-22 09:22:59 -06:00
core.c kcsan: Don't expect 64 bits atomic builtins from 32 bits architectures 2023-06-09 23:29:50 +10:00
debugfs.c kcsan: use u64 instead of cycles_t 2021-07-30 17:09:02 +02:00
encoding.h kcsan: Add missing license and copyright headers 2021-03-08 14:27:43 -08:00
kcsan.h kcsan: Add ability to pass instruction pointer of access to reporting 2021-09-13 16:41:19 -07:00
kcsan_test.c kcsan, compiler_types: Introduce __data_racy type qualifier 2024-05-07 11:39:50 -07:00
Makefile kcsan: avoid passing -g for test 2023-03-23 17:18:35 -07:00
permissive.h kcsan: permissive: Ignore data-racy 1-bit value changes 2021-07-20 13:49:44 -07:00
report.c panic: Consolidate open-coded panic_on_warn checks 2022-12-02 13:04:44 -08:00
selftest.c mm: delete checks for xor_unlock_is_negative_byte() 2023-10-18 14:34:17 -07:00