hlist_add_head_rcu(9)
π hlist_add_head_rcu(9) β the Kernel API Manual, bestie edition π
okay so real talk, this one's from the Kernel API Manual (hlist_add_head_rcu(9)) and it's a little niche but honestly kind of iconic once you get it. stay with me π¦
β¨ NAME β¨
So the NAME section? It's literally empty in the source. Like, nothing. Blank. A whole heading with zero vibes. We move on π (no cap, that's genuinely all it gives us).
πΈ SYNOPSIS πΈ
void hlist_add_head_rcu (struct hlist_node *n , struct hlist_head *h );
that's it, that's the whole signature. short king π
π ARGUMENTS π
nβ the element you're adding to the hash list. the main character, fr fr π«Άhβ the list you're adding it to. it's giving "the venue" ποΈ
π DESCRIPTION π
So what this does: it adds the specified element to the specified hlist, while still permitting racing traversals. Yes, "racing" like concurrent, not like cars ποΈβ¨
Here's the part you actually need to internalize, bestie:
The caller must take whatever precautions are necessary (such as holding appropriate locks) to avoid racing with another list-mutation primitive, such ashlist_add_head_rcuorhlist_del_rcu, running on this same list.
Translation: if something else is mutating this same list at the same time, that's on you to prevent. Locks, your own discipline, whatever precautions the situation calls for β the function is not doing that for you π
Butβand this is the slay partβit is perfectly legal to run concurrently with the _rcu list-traversal primitives, such as hlist_for_each_entry_rcu, which are used to prevent memory-consistency problems on Alpha CPUs. So traversal? concurrent? totally fine. mutation? concurrent? not fine. iykyk π
And regardless of the type of CPU, the list-traversal primitive must be guarded by rcu_read_lock. not "should", must. periodt π₯
π¦ SEE ALSO π¦
Kernel file ./include/linux/rculist.h, plus the whole friend group right 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_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_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)
like, the whole squad showed up πβ¨
π the sign-off π
this little masterpiece lives in ./include/linux, dated October 2026, and you can find it filed under hlist_add_head_rcu(9) π
that's the whole page, bestie β go forth, lock correctly, and may your traversals always be rcu_read_lock-guarded ππ§
π¦ 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