mt_next(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ mt_next(9) ✨

okay so this is a page from the Kernel API Manual bestie, and it's all about mt_next β€” the little function that gets you the next value in the maple tree πŸŒ³πŸ’–


🌸 NAME 🌸

mt_next β€” get the next value in the maple tree 🍁✨


πŸŽ€ SYNOPSIS πŸŽ€

void * mt_next (struct maple_tree *mt , unsigned long index , unsigned long max );

πŸ’… ARGUMENTS πŸ’…

  • mt β€” The maple tree 🌳 (the whole vibe, the actual tree you're poking at)
  • index β€” The start index πŸ‘‰ like, where you begin looking
  • max β€” The maximum index to check 🚧 the hard stop, don't go past this

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea 🍡 β€” mt_next takes the RCU read lock internally to protect the search. Key word: internally. Which means it does not protect the returned pointer once you drop that RCU read lock 😭 so like, don't go thinking the pointer is safe forever just because the search was. It's giving "temporary protection only" energy.

See also: Documentation/core-api/maple_tree.rst πŸ“– (go read it, iykyk)


⭐ RETURN ⭐

The entry higher than index β€” or NULL if nothing is found πŸ™ˆ no cap.


πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./lib/maple_tree.c β€” and literally the whole friend group, because the maple tree API is huge bestie:


πŸ’€ reminder bestie: the RCU read lock is held inside the function only. Once it's dropped, that returned pointer is on its own. Don't be out here dereferencing it like it's got main character protection 🫢

and that's the whole page! this one ships from ./lib and it's dated October 2026 β€” slay, iconic, periodt πŸŽ€βœ¨πŸ’–

πŸ“¦ where this page comes from