hlist_add_behind_rcu(9)
π hlist_add_behind_rcu(9)
okay so bestie, welcome to the Kernel API Manual β¨ this is hlist_add_behind_rcu(9) and honestly she's a whole mood β a little RCU list-splicing icon π
πΈ NAME
hlist_add_behind_rcu -
(yes the original really does just leave that dash hanging there with nothing after it, she's mysterious like that π we support her)
β¨ SYNOPSIS
void hlist_add_behind_rcu (struct hlist_node *n , struct hlist_node
*prev );
like literally that's the whole signature, void in, two struct hlist_node * pointers, no return because she doesn't need to give anything back π
π¦ ARGUMENTS
nβ the new element to add to the hash list. she's the new girl, the fresh node, the main character arriving at the function π«Άprevβ the existing element to add the new element after. like she's the one already in the group chat who's gonna scoot over soncan sit next to her π
π₯ DESCRIPTION
ngl this one is so good: it adds the specified element to the specified hlist after the specified node while permitting racing traversals β¨ that's the whole vibe β insert n right behind prev, and readers doing RCU traversal are not blocked, not even a little bit π
BUT. and this is the important part bestie, do not skip this β the caller must take whatever precautions are necessary (like holding appropriate locks, for example) to avoid racing with another list-mutation primitive, such as hlist_add_head_rcu or hlist_del_rcu, running on this same list. like if two people are editing the same list at the same time it's giving chaos, it's giving undefined-adjacent heartbreak π the mutation side is your problem, not hers.
However!! 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 the readers can be out here doing their read-only little walk while you insert, and that's fine and correct and iconic π₯ (Alpha CPUs catching a stray mention in 2026 is so real of them π)
tl;dr β mutations need your locking, traversals are free to run alongside. don't mix those two up, bestie, fr fr π
π SEE ALSO
Kernel file ./include/linux/rculist.h β plus the whole friend group:
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_head_rcu(9)hlist_add_tail_rcu(9)hlist_add_before_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 that's the whole page! π«Ά this one lives in ./include/linux and the manual dates it October 2026 β so like, future girlie behaviour, we respect it π mwah, go add your node behind the right prev and stay safe out there πβ
π¦ 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