ASSERT_EXCLU...CCESS_SCOPED(9)
β¨ ASSERT_EXCLUSIVE_ACCESS_SCOPED(9) β¨
okay bestie, so this is a page straight out of the Kernel API Manual, section 9 β yes, the kernel one, the big scary one. but don't panic, this one's actually a little cutie π it's called ASSERT_EXCLUSIVE_ACCESS_SCOPED, and it's here to help you prove nobody's touching your variable while you're vibing in your scope. let's get into it π
πΈ NAME πΈ
ASSERT_EXCLUSIVE_ACCESS_SCOPED β assert no concurrent accesses to @var in scope
like, literally, that's the whole gig. you're asserting that nobody else is accessing your variable for the whole scope. periodt. π
π¦ SYNOPSIS π¦
ASSERT_EXCLUSIVE_ACCESS_SCOPED (var );
that's it. that's the whole call. cute, right? π«Ά
β ARGUMENTS β
varβ the variable you're asserting on. your main character variable, if you will. this is the thing you're promising nobody else is touching. β¨
π DESCRIPTION π
okay so this is the scoped variant of ASSERT_EXCLUSIVE_ACCESS β the glow-up version, if you will π
what it does: it asserts that there are no concurrent accesses to var β and that means no readers and no writers, not a single one β for the entire duration of the scope in which it's introduced. the whole scope. from start to finish. no sneaky little access slipping in halfway through. π
and why is this iconic? because it's genuinely a better way to fully cover the enclosing scope, compared to stacking up multiple ASSERT_EXCLUSIVE_ACCESS calls like some kind of manual effort. one macro, whole scope covered. the way that it just handles the entire duration for you?? obsessed. π₯
bonus: it increases the likelihood for KCSAN to detect racing accesses β so like, you're giving KCSAN a better shot at catching the racing accesses if they're being shady. kcsan said "not on my watch" π
ngl, the whole point here is coverage. if you sprinkle individual asserts you might miss a spot mid-scope. this one's got the scope's back the entire time. no cap. π§
π SEE ALSO π
so many siblings, honestly, this macro has a huge family. here's the whole group chat π«Ά
the file it lives in:
- Kernel file
./include/linux/kcsan-checks.h
the kcsan check crew:
the enable/disable girlies:
the atomic pair squad:
kcsan_nestable_atomic_begin(9)kcsan_nestable_atomic_end(9)kcsan_flat_atomic_begin(9)kcsan_flat_atomic_end(9)kcsan_atomic_next(9)
mask + scoped access besties:
the check triad(s):
__kcsan_check_read(9)__kcsan_check_write(9)__kcsan_check_read_write(9)kcsan_check_read(9)kcsan_check_write(9)kcsan_check_read_write(9)
the ASSERT_EXCLUSIVE fam:
ASSERT_EXCLUSIVE_WRITER(9)ASSERT_EXCLUSIVE_WRITER_SCOPED(9)ASSERT_EXCLUSIVE_ACCESS(9)ASSERT_EXCLUSIVE_BITS(9)
lowkey that's a lot of references but like... they're all doing related things, iykyk π
and that's the page!! this came from ./include/linux, dated October 2026, and we're out here in section 9 of the Kernel API Manual. go forth and scope your asserts, bestie β you're gonna slay it ππβ¨π¦
π¦ 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