Skip to content

Commit e675d25

Browse files
melverpaulmckrcu
authored andcommitted
kcsan: Introduce CONFIG_KCSAN_STRICT
Add a simpler Kconfig variable to configure KCSAN's "strict" mode. This makes it simpler in documentation or messages to suggest just a single configuration option to select the strictest checking mode (vs. currently having to list several options). Signed-off-by: Marco Elver <elver@google.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 parent a7a7369 commit e675d25

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

Documentation/dev-tools/kcsan.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ Kconfig options:
127127
causes KCSAN to not report data races due to conflicts where the only plain
128128
accesses are aligned writes up to word size.
129129

130+
To use the strictest possible rules, select ``CONFIG_KCSAN_STRICT=y``, which
131+
configures KCSAN to follow the Linux-kernel memory consistency model (LKMM) as
132+
closely as possible.
133+
130134
DebugFS interface
131135
~~~~~~~~~~~~~~~~~
132136

lib/Kconfig.kcsan

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,17 @@ config KCSAN_REPORT_RACE_UNKNOWN_ORIGIN
183183
reported if it was only possible to infer a race due to a data value
184184
change while an access is being delayed on a watchpoint.
185185

186+
config KCSAN_STRICT
187+
bool "Strict data-race checking"
188+
help
189+
KCSAN will report data races with the strictest possible rules, which
190+
closely aligns with the rules defined by the Linux-kernel memory
191+
consistency model (LKMM).
192+
186193
config KCSAN_REPORT_VALUE_CHANGE_ONLY
187194
bool "Only report races where watcher observed a data value change"
188195
default y
196+
depends on !KCSAN_STRICT
189197
help
190198
If enabled and a conflicting write is observed via a watchpoint, but
191199
the data value of the memory location was observed to remain
@@ -194,6 +202,7 @@ config KCSAN_REPORT_VALUE_CHANGE_ONLY
194202
config KCSAN_ASSUME_PLAIN_WRITES_ATOMIC
195203
bool "Assume that plain aligned writes up to word size are atomic"
196204
default y
205+
depends on !KCSAN_STRICT
197206
help
198207
Assume that plain aligned writes up to word size are atomic by
199208
default, and also not subject to other unsafe compiler optimizations
@@ -206,6 +215,7 @@ config KCSAN_ASSUME_PLAIN_WRITES_ATOMIC
206215

207216
config KCSAN_IGNORE_ATOMICS
208217
bool "Do not instrument marked atomic accesses"
218+
depends on !KCSAN_STRICT
209219
help
210220
Never instrument marked atomic accesses. This option can be used for
211221
additional filtering. Conflicting marked atomic reads and plain

0 commit comments

Comments
 (0)