latch_tree_find(9)
π latch_tree_find(9) β a Kernel API Manual moment β¨
okay so this is latch_tree_find(9) from the Kernel API Manual, and honestly? she's giving lockless-search-icon realness and we're obsessed π
πΈ NAME πΈ
latch_tree_find β literally finds the node matching @key in the trees @root, no cap π«Ά
β¨ SYNOPSIS β¨
struct latch_tree_node * latch_tree_find (void *key , struct
latch_tree_root *root , const struct latch_tree_ops *ops );
yeah bestie, that's the whole signature, copy it exactly, don't be weird about the spacing π
π¦ ARGUMENTS π¦
keyβ the search key, like, the thing you're looking for πrootβ the trees to search forkey, plural trees, she contains multitudes πopsβ the operators defining the node order, the vibe-check-rules basically β
π DESCRIPTION π
so what she does: does a lockless lookup in the trees root for the node matching key. lockless! no locks! main character energy, she just goes β¨
β οΈ big caveat bestie: it is assumed that this is called while holding the appropriate RCU read side lock. like, that's the whole premise. don't skip that part fr fr π
and here's the messy part π β if the operators define a partial order on the elements (meaning there are multiple elements which have the same key value), then it is undefined which of these elements will be found. undefined! not "whichever one you want", not "the first one", literally undefined π
nor is it possible to iterate the tree to find further elements with the same key value. so like, one look, one shot, that's it, no scrolling for more π«
π RETURN π
a pointer to the node matching key or NULL. that's it. she either ate or she gave you nothing π
π SEE ALSO π
- Kernel file
./include/linux/rbtree_latch.h struct latch_tree_ops(9)latch_tree_insert(9)latch_tree_erase(9)
and that's the whole page, bestie π§π this little gem lives in ./include/linux, it's dated October 2026, and it's filed under latch_tree_find(9) β go forth and find your nodes responsibly π
πΈβ¨
π¦ 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