On 2024-03-06 21:43, Linus Torvalds wrote: [...]
Honestly, this all makes me think that we'd be *much* better off showing the real "handoff" with smp_store_release() and smp_load_acquire().
We've done something similar in liburcu (userspace code) to allow Thread Sanitizer to understand the happens-before relationships within the RCU implementations and lock-free data structures. Moving to load-acquire/store-release (C11 model in our case) allowed us to provide enough happens-before relationship for Thread Sanitizer to understand what is happening under the hood in liburcu and perform relevant race detection of user code. As far as the WRITE_ONCE(x, READ_ONCE(x) + 1) pattern is concerned, the only valid use-case I can think of is split counters or RCU implementations where there is a single updater doing the increment, and one or more concurrent reader threads that need to snapshot a consistent value with READ_ONCE(). Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com