mt_next(9)
β¨ 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 lookingmaxβ 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:
mas_prealloc_calc(9)mas_wr_preallocate(9)mas_insert(9)mas_alloc_cyclic(9)mas_walk(9)mte_dead_walk(9)mt_free_walk(9)mas_store(9)mas_store_gfp(9)mas_store_prealloc(9)mas_preallocate(9)mas_next(9)mas_next_range(9)mas_prev(9)mas_prev_range(9)mt_prev(9)mas_pause(9)mas_find_setup(9)mas_find(9)mas_find_range(9)mas_find_rev_setup(9)mas_find_rev(9)mas_find_range_rev(9)mas_erase(9)mas_nomem(9)mas_nomem_nofail(9)mtree_load(9)mtree_store_range(9)mtree_store(9)mtree_insert_range(9)mtree_insert(9)mtree_alloc_cyclic(9)mtree_erase(9)__mt_dup(9)mtree_dup(9)__mt_destroy(9)mtree_destroy(9)mt_find(9)mt_find_after(9)
π 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
- 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