list_for_each_entry_srcu(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 the list_head within 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 🌈:


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