list_for_eac...try_lockless(9)
π 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:
- running within a special exception-time environment where preemption is disabled and where lockdep cannot be invoked π₯
- 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 π
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_for_each_entry_srcu(9)list_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)
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
- 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