Skip to content

Commit

Permalink
tools/memory-model: Make read_foo_diagnostic() more clearly diagnostic
Browse files Browse the repository at this point in the history
The current definition of read_foo_diagnostic() in the "Lock Protection
With Lockless Diagnostic Access" section returns a value, which could
be use for any purpose.  This could mislead people into incorrectly
using data_race() in cases where READ_ONCE() is required.  This commit
therefore makes read_foo_diagnostic() simply print the value read.

Reported-by: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
  • Loading branch information
Paul E. McKenney committed Jul 20, 2021
1 parent 2734d6c commit 1846a7f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/memory-model/Documentation/access-marking.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ diagnostic purposes. The code might look as follows:
return ret;
}

int read_foo_diagnostic(void)
void read_foo_diagnostic(void)
{
return data_race(foo);
pr_info("Current value of foo: %d\n", data_race(foo));
}

The reader-writer lock prevents the compiler from introducing concurrency
Expand Down

0 comments on commit 1846a7f

Please sign in to comment.