lkml.org 
[lkml]   [2021]   [Jul]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH memory-model 3/4] tools/memory-model: Heuristics using data_race() must handle all values
    Date
    From: Manfred Spraul <manfred@colorfullife.com>

    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 be7d507997cf8..fe4ad6d12d24c 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
    --
    2.31.1.189.g2e36527f23
    \
     
     \ /
      Last update: 2021-07-21 23:11    [W:3.556 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site