list_for_eac...try_lockless(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… list_for_each_entry_lockless(9) β€” like, the lockless list vibe πŸ¦‹

okay bestie, so this is a page straight out of the Kernel API Manual, section 9, and the page is literally called list_for_eac...try_lockless(9) (yes the title got truncated in the header, no that's not a typo on my part, it's just giving terminal-width energy πŸ’€). anyway. sit down, grab a boba, we're looping over lists today. ✨


🌸 NAME 🌸

list_for_each_entry_lockless β€” iterate over rcu list of given type

periodt. that's the whole name section. iconic brevity.


✨ SYNOPSIS ✨

list_for_each_entry_lockless (pos , head , member );

not me putting it in a code block so your eyes don't glaze over 🫢 copy it exactly, the spacing is canon.


πŸŽ€ ARGUMENTS πŸŽ€

three args, three chances to mess it up, let's go:

  • pos β€” the type * to use as a loop cursor. literally your main character variable, she walks the list for you πŸ’…
  • head β€” the head for your list. the starting point, the home base, the group chat admin 🌈
  • member β€” the name of the list_struct within the struct. telling the macro which field inside your struct is the actual list node, iykyk 🧚

πŸ’– DESCRIPTION πŸ’–

so here's the tea: this primitive may safely run concurrently with the _rcu list-mutation primitives such as list_add_rcu, but β€” and this is the important part, don't scroll past it β€” it requires some implicit RCU read-side guarding. 🫢

"implicit" meaning you don't see it, but it lowkey has to be there. it's giving "trust me bro" but in a kernel-legal way.

two examples the page gives for when that's chill:

  1. running within a special exception-time environment where preemption is disabled and where lockdep cannot be invoked πŸ”₯
  2. when items are added to the list, but never deleted β€” nothing leaves, so nothing can bite you on the way out πŸ¦‹
bestie warning: "implicit RCU read-side guarding" is doing a LOT of heavy lifting in that sentence. if neither of those two situations describes what you're doing, do not just vibe-check your way into using this. 😭

πŸ‘‘ SEE ALSO πŸ‘‘

the page points you at the kernel file ./include/linux/rculist.h, and then proceeds to dump the entire friend group. not me listing all of them, but like β€” all of them. no skipping, we don't do that here πŸ’œ

and yeah, list_entry_lockless(9) right there in the middle is basically this page's sibling, go say hi πŸ“


okay that's the whole thing, you ate that πŸ’…

this little love letter came to you from ./include/linux, dated October 2026, and the footer's version line is literally list_for_eac...try_lockless(9) again β€” the header and footer are matching, that's called commitment, we stan a consistent layout. mwah. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from