Skip to content

Commit 1846a7f

Browse files
committed
tools/memory-model: Make read_foo_diagnostic() more clearly diagnostic
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>
1 parent 2734d6c commit 1846a7f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ diagnostic purposes. The code might look as follows:
259259
return ret;
260260
}
261261

262-
int read_foo_diagnostic(void)
262+
void read_foo_diagnostic(void)
263263
{
264-
return data_race(foo);
264+
pr_info("Current value of foo: %d\n", data_race(foo));
265265
}
266266

267267
The reader-writer lock prevents the compiler from introducing concurrency

0 commit comments

Comments
 (0)