On 11/9/25 2:37 AM, Nilay Shroff wrote:
On 11/7/25 9:48 PM, Bart Van Assche wrote:
No. As the comment above the data_race() macro explains, the data_race() macro makes memory accesses invisible to KCSAN. Hence, annotating writers only with data_race() is sufficient.
If the data access is marked using one of READ_ONCE(), WRITE_ONCE(), or data_race(), then KCSAN would not instrument that access. However, plain accesses are always instrumented.
So, if we only mark the writers but keep the readers as plain accesses, KCSAN would likely report a race at unknown origin — because the plain read access is still being watched, and when the variable’s value changes, it’s detected as a data race. This is exactly what I observed and reported earlier with this change.
KCSAN watchpoints do not include the value of a memory location. Hence, I think that the above conclusion that KCSAN would report data races against writes marked with data_race() is wrong.
Bart.