list_add_rcu(9)
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
- 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