srcu_read_lock(9)
π srcu_read_lock β the kernel API manual, but make it make sense
okay so bestie, welcome to srcu_read_lock(9) β this is the Kernel API Manual page for the SRCU reader-registration function, and yes we're gonna get into it π
β¨ NAME β¨
srcu_read_lock β register a new reader for an SRCU-protected structure. that's it, that's the whole vibe. you're clocking in as a reader πβ¨
π SYNOPSIS π
int srcu_read_lock (struct srcu_struct *ssp );
πΈ ARGUMENTS πΈ
sspβ thesrcu_structyou're registering this shiny new reader into. this is the structure you're claiming reader status on, no cap π«Ά
π DESCRIPTION π
so what this actually does: it enters an SRCU read-side critical section. you're in it now, bestie, main character energy, the section is yours π
and lowkey the nice part β SRCU read-side critical sections may be nested. go ahead, stack 'em, we love a nestable situation β¨
β οΈ but here's the part where you don't get to be chaotic: it is illegal to call anything that waits on an SRCU grace period for the samesrcu_struct, whether directly or indirectly. and yes, indirect counts β please note that one way to indirectly wait on an SRCU grace period is to acquire a mutex that is held elsewhere while callingsynchronize_srcuorsynchronize_srcu_expedited. so likeβ¦ don't do that π that's a whole deadlock situation waiting to happen and not in a cute way π
okay now the return value, this is important, pay attention π
The return value from srcu_read_lock is guaranteed to be non-negative. That value must be passed unaltered to the matching srcu_read_unlock. unaltered!! do not touch it, do not "improve" it, do not pass something adjacent β it goes in exactly as it came out, periodt π
π¦ and one more:srcu_read_lockand the matchingsrcu_read_unlockmust occur in the same context. for example, it is illegal to invokesrcu_read_unlockin an irq handler if the matchingsrcu_read_lockwas invoked in process context. or, for that matter, to invokesrcu_read_unlockfrom one task and the matchingsrcu_read_lockfrom another. the lock/unlock pair is a package deal, they stay together, fr fr π
π₯ SEE ALSO π₯
Kernel file ./include/linux/srcu.h β and like, the whole extended SRCU family reunion:
get_completed_synchronize_srcu(9)same_state_synchronize_srcu(9)srcu_read_lock_held(9)srcu_dereference_check(9)srcu_dereference(9)srcu_dereference_notrace(9)srcu_read_lock_fast(9)srcu_read_lock_fast_updown(9)srcu_down_read_fast(9)srcu_read_lock_nmisafe(9)srcu_down_read(9)srcu_read_unlock(9)srcu_read_unlock_fast(9)srcu_read_unlock_fast_updown(9)srcu_up_read_fast(9)srcu_read_unlock_nmisafe(9)srcu_up_read(9)smp_mb__after_srcu_read_unlock(9)smp_mb__after_srcu_read_lock(9)
and that's the page, bestie π§π this iconic little number lives in ./include/linux, dated October 2026, and it's filed under srcu_read_lock(9). go forth and register your readers responsibly, mwah ππΈ
π¦ 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