rcu_read_lock_held(9)
π rcu_read_lock_held(9) β a Kernel API Manual moment
okay so we're deep in the kernel manual bestie, welcome to rcu_read_lock_held(9) π this is the Kernel API Manual and honestly? this little function is doing the most for your debug checks and it deserves its flowers πΈ
β¨ NAME β¨
rcu_read_lock_held β literally "might we be in RCU read-side critical section?" like that's the whole vibe check π
π¦ SYNOPSIS π¦
int notrace rcu_read_lock_held (void );
πΈ ARGUMENTS πΈ
voidβ no arguments, babe. zero. none. she takes nothing and she gives everything β¨
π DESCRIPTION π
okay so here's the tea π: if CONFIG_DEBUG_LOCK_ALLOC is selected, this returns nonzero iff you're in an RCU read-side critical section. iykyk π
in the absence of CONFIG_DEBUG_LOCK_ALLOC, this one just assumes we are in an RCU read-side critical section unless it can prove otherwise. she's trusting like that π«Ά this is useful for debug checks in functions that require that they be called within an RCU read-side critical section β basically "hey are you where you're supposed to be" energy π₯
she also checks debug_lockdep_rcu_enabled to prevent false positives during boot and while lockdep is disabled. thoughtful queen π
β οΈ note bestie:rcu_read_lockand the matchingrcu_read_unlockmust occur in the same context. for example, it is illegal to invokercu_read_unlockin process context if the matchingrcu_read_lockwas invoked from within an irq handler. like... do not do that. that's a no from me π
β οΈ also note: rcu_read_lock is disallowed if the CPU is either idle or offline from an RCU perspective, so check for those as well. main character energy requires a CPU that's actually online, fr fr π
π SEE ALSO π
Kernel file ./kernel/rcu/update.c
rcu_read_lock_held_common(9)rcu_async_hurry(9)rcu_async_relax(9)rcu_expedite_gp(9)rcu_unexpedite_gp(9)rcu_read_lock_bh_held(9)wakeme_after_rcu(9)init_rcu_head_on_stack(9)destroy_rcu_head_on_stack(9)get_completed_synchronize_rcu(9)
the whole friend group, iconic lineup honestly ππ
and that's the page!! π« brought to you by ./kernel/rcu, dated October 2026, and signed off with so much love β go forth and check your RCU contexts responsibly bestie π§π
π¦ 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