STRUCT LATCH_TREE_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct latch_tree_ops(9)

okay so bestie, welcome to the Kernel API Manual β€” this one's about struct latch_tree_ops, which is literally just the little bundle of function pointers that tells a latch tree how to order itself. no cap, that's the whole vibe. πŸŽ€


✨ NAME ✨

struct latch_tree_ops β€” the operators that define the tree order 🌸


πŸ¦‹ SYNOPSIS πŸ¦‹

struct latch_tree_ops {
    bool (*less)(struct latch_tree_node *a, struct latch_tree_node *b);
    int (*comp)(void *key,                 struct latch_tree_node *b);
 };

πŸ’… Members πŸ’…

  • less β€” this one's for insertion, periodt. it hands you the (partial) order between two elements. 🫢
  • comp β€” this one's for lookups. it gives you the order between the search key and an element. πŸ”

πŸ‘‘ Description πŸ‘‘

ok so these two operators are lowkey in a whole relationship with each other, and it goes like this:

comp(a->key,b) < 0  := less(a,b) comp(a->key,b) > 0  := less(b,a)
comp(a->key,b) == 0 := !less(a,b) && !less(b,a)

heads up though 🚨 β€” if these operators define a partial order on the elements, we make no guarantee about which of the elements matching the key actually gets found. so like, don't come for us if you get a different one than you expected, mwah. πŸ’‹ go look at latch_tree_find if you wanna know more.


πŸ”₯ SEE ALSO πŸ”₯


k bye bestie, this page lives in ./include/linux, comes from the Kernel API Manual era of October 2026, and it's still serving struct latch_tree_ops(9) energy πŸ’œβœ¨ go slay your rbtree latches πŸ§šβ€β™€οΈ

πŸ“¦ where this page comes from