mtree_insert_range(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– NAME πŸ’–

mtree_insert_range β€” bestie, this is the one that drops an entry into a range [first, last] only if there's no value there already. Like, it's not gonna fight something that's already occupying the spot. No cap. ✨

(Oh and hey, we're in the Kernel API Manual today β€” kernel girlies rise up 🫢)


✨ SYNOPSIS ✨

int mtree_insert_range (struct maple_tree *mt , unsigned long first ,
unsigned long last , void *entry , gfp_t gfp );

πŸŽ€ ARGUMENTS πŸŽ€

  • mt β€” the maple tree itself, the main character we're all here for πŸŒ³πŸ‘‘
  • first β€” where the range starts
  • last β€” where the range ends, and yes it's inclusive πŸ’…
  • entry β€” the thing you want to store, your precious little payload 🎁
  • gfp β€” the GFP_FLAGS used for allocations ✨

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so real talk: last is inclusive. Not "inclusive-ish", not "kinda", literally inclusive. So this is the math you want, iykyk:

last = first + length - 1

Write that down, bestie, because off-by-one errors are not the vibe 😭


🌸 RETURN 🌸

  • 0 β€” slayed, it worked ✨
  • -EEXISTS β€” nope, the range is already occupied, someone got there first πŸ’€
  • -EINVAL β€” invalid request, like... what were you even trying to do πŸ™ˆ
  • -ENOMEM β€” couldn't allocate memory, the allocations said "not today" 😭

πŸ’œ SEE ALSO πŸ’œ

Kernel file ./lib/maple_tree.c β€” and the whole friend group, fr fr:


Reminder bestie: last = inclusive. Do NOT come crying to me when you forget. 🫢

Okay that's the whole page β€” from ./lib, the October 2026 edition, mwah πŸ’‹ go forth and insert those ranges responsibly πŸ”₯

πŸ“¦ where this page comes from