tools/memory-model: Make read_foo_diagnostic() more clearly diagnostic
authorPaul E. McKenney <paulmck@kernel.org>
Thu, 13 May 2021 18:17:02 +0000 (11:17 -0700)
committerPaul E. McKenney <paulmck@kernel.org>
Tue, 20 Jul 2021 20:52:03 +0000 (13:52 -0700)
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>
tools/memory-model/Documentation/access-marking.txt

index 1ab189f..58bff26 100644 (file)
@@ -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