rb_add_cached(9)
πΈ rb_add_cached(9) πΈ
okay so bestie, welcome to the Kernel API Manual β yes, THE kernel API manual, we're in the big leagues now π
this one's about rb_add_cached(9), and it's lowkey one of the most satisfying little helpers in the whole tree. sit down, hydrate, let's go π«Ά
β¨ NAME β¨
rb_add_cached β insert @node into the leftmost cached tree @tree π
like, that's literally the whole vibe. you have a node, you have a cached tree, you put the node in the tree. slay.
π SYNOPSIS π
void rb_add_cached (struct rb_node *node , struct rb_root_cached *tree ,
bool (*less)(struct rb_node *, const struct rb_node *) );
ok so look at this signature, it's giving very demure very mindful β returns void, takes three things, no cap. the (*less) function pointer is the main character here, iykyk π
π¦ ARGUMENTS π¦
nodeβ the node you wanna insert π this is the little guy going into the tree, treat it nice.treeβ the leftmost cached tree you're insertingnodeinto π³ it's cached, it's leftmost, it's iconic, it's exactly what it says on the tin.lessβ the operator that defines the (partial) node order β note the word partial, bestie, we're not out here assuming a total order, that's not the assignment. this bad boy isbool (*less)(struct rb_node *, const struct rb_node *)and it decides who goes where.
π SEE ALSO π
the receipts, in original order, no edits fr fr π
- Kernel file
./tools/include/linux/rbtree.hβ go read the source, it's right there, be nosy π rbtree_postorder_for_each_entry_safe(9)rb_add(9)rb_find_add(9)rb_find(9)rb_find_first(9)rb_next_match(9)rb_for_each(9)
like, the whole rbtree friend group showed up to the function. obsessed π₯
ngl the only thing better than reading the manpage is reading the actual header file, so go click on ./tools/include/linux/rbtree.h when you're done here π
okay that's the whole page, mwah π this cutie came to you from ./tools/include/linux, dated October 2026 β mark your calendars, screenshot it, frame it, whatever, periodt π§ββοΈβ¨
π¦ 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