list_for_each_entry_srcu(9)
π list_for_each_entry_srcu β a lil intro
okay so first things first, bestie: this page lives in the Kernel API Manual β¨ (yes, that kernel, and yes, we're being cute about it). Buckle up, because this one is a loop macro and it's genuinely iconic π
β¨ NAME β¨
list_for_each_entry_srcu β iterate over rcu list of given type π¦
πΈ SYNOPSIS πΈ
list_for_each_entry_srcu (pos , head , member , cond );
π ARGUMENTS π
posβ the type * to use as a loop cursor. this is your main character pointer, she walks the list for you πheadβ the head for your list. the origin, the queen bee πmemberβ the name of thelist_headwithin the struct. iykyk, it's the lil field that makes the struct listable π§condβ lockdep expression for the lock required to traverse the list. this is the vibe check for your locking, fr fr π
π DESCRIPTION π
so here's the tea π: this list-traversal primitive may safely run concurrently with the _rcu list-mutation primitives such as list_add_rcu as long as the traversal is guarded by srcu_read_lock. literally that's the whole deal β no cap.
and the lockdep expression srcu_read_lock_held can be passed as the cond argument from the read side. so you get the safety check and the traversal, cute and correct at the same time πβ¨
bestie pls note: the "may safely run concurrently" part is conditional on that srcu_read_lock guard β don't skip it, that's not a vibe, that's a bug π
π¦ SEE ALSO π¦
Kernel file ./include/linux/rculist.h β and honestly the whole rcu family showed up to the group chat π:
list_for_each_rcu(9)list_tail_rcu(9)list_add_rcu(9)list_add_tail_rcu(9)list_del_rcu(9)list_bidir_del_rcu(9)hlist_del_init_rcu(9)list_replace_rcu(9)list_splice_rcu(9)__list_splice_init_rcu(9)list_splice_init_rcu(9)list_splice_tail_init_rcu(9)list_entry_rcu(9)list_first_or_null_rcu(9)list_next_or_null_rcu(9)list_for_each_entry_rcu(9)list_entry_lockless(9)list_for_each_entry_lockless(9)list_for_each_entry_continue_rcu(9)list_for_each_entry_from_rcu(9)hlist_del_rcu(9)hlist_replace_rcu(9)hlists_swap_heads_rcu(9)hlist_add_head_rcu(9)hlist_add_tail_rcu(9)hlist_add_before_rcu(9)hlist_add_behind_rcu(9)hlist_for_each_entry_rcu(9)hlist_for_each_entry_srcu(9)hlist_for_each_entry_rcu_notrace(9)hlist_for_each_entry_rcu_bh(9)hlist_for_each_entry_continue_rcu(9)hlist_for_each_entry_continue_rcu_bh(9)hlist_for_each_entry_from_rcu(9)
okay that's the whole page, you ate that π«Ά signing off from ./include/linux, dated October 2026, page list_for_each_entry_srcu(9) β slay, go guard your traversal, 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