list_add_rcu(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

Hey bestie! So there's this kernel function called list_add_rcu and it lives in the Kernel API Manual (section 9, for all you manual-page girlies). Let me spill the tea on what it does πŸ’…


πŸ’– NAME πŸ’–

list_add_rcu β€” add a new entry to an rcu-protected list


🌸 SYNOPSIS 🌸

void list_add_rcu (struct list_head *new , struct list_head *head );

πŸŽ€ ARGUMENTS πŸŽ€

  • new β€” the shiny new entry you're adding, bestie ✨
  • head β€” the list head you're adding it after, no cap

✨ DESCRIPTION ✨

Okay so the vibe is: insert a new entry right after the specified head. This is lowkey perfect for implementing stacks πŸ”₯

BUTβ€”and this is a big BUTβ€”the caller has to take whatever precautions are necessary (like holding appropriate locks) to avoid racing with another list-mutation primitive, such as list_add_rcu or list_del_rcu, running on this same list. Fr fr, do not skip this step or it's giving undefined chaos πŸ™ˆ

However! It is perfectly legal to run concurrently with the _rcu list-traversal primitives, such as list_for_each_entry_rcu. So you can absolutely read while you write, periodt πŸ‘‘

⚠️ Warning bestie: racing two list mutations without locks is a no-no. The traversal side is chill, the mutation side is NOT. Keep that in mind πŸ’€

🌈 SEE ALSO 🌈

Kernel file ./include/linux/rculist.h β€” and here's the whole squad of related fam:

list_for_each_rcu(9), list_tail_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_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)


Mwah! 😘 This page is chillin' in ./include/linux and it's dated October 2026 πŸ—“οΈ Go forth and slay those linked lists, bestie πŸ’œβœ¨

πŸ“¦ where this page comes from