rcu_read_lock_held_common(9)
π rcu_read_lock_held_common β kernel api manual, bestie edition π
okay so this is rcu_read_lock_held_common(9) from the Kernel API Manual and honestly? it's giving "am I actually in an RCU-sched read-side critical section or am I delulu" energy. let's get into it β¨
πΈ NAME πΈ
rcu_read_lock_held_common β might we be in RCU-sched read-side critical section? π€
β¨ SYNOPSIS β¨
bool rcu_read_lock_held_common (bool *ret );
π¦ ARGUMENTS π¦
retβ the best guess answer, but ONLY when lockdep can't be relied on. like, it's the backup plan, the understudy, the "if the main character doesn't show up" answer π
π DESCRIPTION π
okay so here's the vibe check. this function returns true if lockdep must be ignored, and in that case *ret holds the best guess described down below π. otherwise it returns false, and in that case *ret tells the caller literally nothing β nope, nada, zero information β and the caller should instead go consult lockdep directly. no cap. π
if CONFIG_DEBUG_LOCK_ALLOC is selected, it sets *ret to nonzero iff we're in an RCU-sched read-side critical section. if CONFIG_DEBUG_LOCK_ALLOC is not around? then this just assumes we're in an RCU-sched read-side critical section unless it can prove otherwise. icon behavior honestly. also note that disabling of preemption (including disabling irqs) counts as an RCU-sched read-side critical section π β this whole thing is super useful for debug checks in functions that required that they be called within an RCU-sched read-side critical section. periodt.
check debug_lockdep_rcu_enabled to prevent false positives during boot and while lockdep is disabled π«Ά (we love a preemptive vibe check).
π real talk though: note that if the CPU is in the idle loop from an RCU point of view (ie: that we are in the section betweenct_idle_enterandct_idle_exit) thenrcu_read_lock_heldsets*retto false even if the CPU did anrcu_read_lock. the reason for this is that RCU ignores CPUs that are in such a section, considering these as in extended quiescent state, so such a CPU is effectively never in an RCU read-side critical section regardless of what RCU primitives it invokes. literally never, no matter how hard it tries π
and the way this state of affairs is required β we need to keep an RCU-free window in idle where the CPU may possibly enter into low power mode. this way we can notice an extended quiescent state to other CPUs that started a grace period π. otherwise we would delay any grace period as long as we run in the idle task. not slay. not it.
similarly (fr fr), we avoid claiming an RCU read lock held if the current CPU is offline. offline CPU said "not me, not today" β
π₯ SEE ALSO π₯
kernel file ./kernel/rcu/update.c plus these icons:
rcu_async_hurry(9)rcu_async_relax(9)rcu_expedite_gp(9)rcu_unexpedite_gp(9)rcu_read_lock_held(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, obsessed π
that's the whole page bestie, brought to you by ./kernel/rcu, dated October 2026, serving rcu_read_lock_held_common(9) realness π
β¨ go be iconic in your critical section π§π
π¦ 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