Skip to content

Commit f92975d

Browse files
manfred-colorfupaulmckrcu
authored andcommitted
tools/memory-model: Heuristics using data_race() must handle all values
Data loaded for use by some sorts of heuristics can tolerate the occasional erroneous value. In this case the loads may use data_race() to give the compiler full freedom to optimize while also informing KCSAN of the intent. However, for this to work, the heuristic needs to be able to tolerate any erroneous value that could possibly arise. This commit therefore adds a paragraph spelling this out. Signed-off-by: Manfred Spraul <manfred@colorfullife.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 parent 436eef2 commit f92975d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

tools/memory-model/Documentation/access-marking.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ consistent errors, which in turn are quite capable of breaking heuristics.
126126
Therefore use of data_race() should be limited to cases where some other
127127
code (such as a barrier() call) will force the occasional reload.
128128

129+
Note that this use case requires that the heuristic be able to handle
130+
any possible error. In contrast, if the heuristics might be fatally
131+
confused by one or more of the possible erroneous values, use READ_ONCE()
132+
instead of data_race().
133+
129134
In theory, plain C-language loads can also be used for this use case.
130135
However, in practice this will have the disadvantage of causing KCSAN
131136
to generate false positives because KCSAN will have no way of knowing

0 commit comments

Comments
 (0)