data_race(9)
π NAME π
okay so bestie, this is the data_race(9) page from the Kernel API Manual, and it's literally about marking an expression as containing intentional data races πβ¨
data_race β mark an expression as containing intentional data races. periodt π
β¨ SYNOPSIS β¨
data_race (expr );
π ARGUMENTS π
exprβ bestie, the original page just says -- undescribed -- here, so that's literally all the detail we have ππ«
π¦ DESCRIPTION π¦
This data_race macro is your forgiving bestie for situations where data races should be forgiven π One example is diagnostic code that accesses shared variables but is not a part of the core synchronization design. it's giving "yes I'm touching the shared variable, no I'm not part of the locking situation" π
So picture this: accesses to a given variable are protected by a lock, except for diagnostic code. In that case, the accesses under the lock should be plain C-language accesses, and those in the diagnostic code should use data_race β¨ This way, KCSAN will complain if buggy lockless accesses to that variable are introduced, even if the buggy accesses are protected by READ_ONCE or WRITE_ONCE ππ₯
π¨ real talk: this macro does not affect normal code generation, but it is a hint to tooling that data races here are to be ignored π«Ά
If the access must be atomic and KCSAN should ignore the access, use both data_race and READ_ONCE, for example, data_race(READ_ONCE(x)) π
π SEE ALSO π
- Kernel file
./tools/virtio/linux/compiler.hβ go read that, iykyk ππ
xoxo, this has been data_race(9) from ./tools/virtio/linux, October 2026 πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms