linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [tip: locking/debug] tools/memory-model: Heuristics using data_race() must handle all values
@ 2021-08-18  7:58 tip-bot2 for Manfred Spraul
  0 siblings, 0 replies; only message in thread
From: tip-bot2 for Manfred Spraul @ 2021-08-18  7:58 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Manfred Spraul, Paul E. McKenney, x86, linux-kernel

The following commit has been merged into the locking/debug branch of tip:

Commit-ID:     f92975d76d537c06a2118f9c3c63432c0f7c7a88
Gitweb:        https://git.kernel.org/tip/f92975d76d537c06a2118f9c3c63432c0f7c7a88
Author:        Manfred Spraul <manfred@colorfullife.com>
AuthorDate:    Fri, 14 May 2021 11:40:06 -07:00
Committer:     Paul E. McKenney <paulmck@kernel.org>
CommitterDate: Tue, 27 Jul 2021 11:48:55 -07:00

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>
---
 tools/memory-model/Documentation/access-marking.txt | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/memory-model/Documentation/access-marking.txt b/tools/memory-model/Documentation/access-marking.txt
index d96fe20..82a4899 100644
--- a/tools/memory-model/Documentation/access-marking.txt
+++ b/tools/memory-model/Documentation/access-marking.txt
@@ -126,6 +126,11 @@ consistent errors, which in turn are quite capable of breaking heuristics.
 Therefore use of data_race() should be limited to cases where some other
 code (such as a barrier() call) will force the occasional reload.
 
+Note that this use case requires that the heuristic be able to handle
+any possible error.  In contrast, if the heuristics might be fatally
+confused by one or more of the possible erroneous values, use READ_ONCE()
+instead of data_race().
+
 In theory, plain C-language loads can also be used for this use case.
 However, in practice this will have the disadvantage of causing KCSAN
 to generate false positives because KCSAN will have no way of knowing

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-18  7:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-18  7:58 [tip: locking/debug] tools/memory-model: Heuristics using data_race() must handle all values tip-bot2 for Manfred Spraul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).