radix_tree_next_slot(9)
β¨ radix_tree_next_slot β¨
Okay so bestie, this is a function from the Kernel API Manual and it's literally all about finding the next slot in a chunk. No cap, it's giving "where's the next one, bestie?" energy and we're gonna get into it. π
πΈ NAME πΈ
radix_tree_next_slot β find next slot in chunk
Like, it finds the next slot. In a chunk. That's the whole vibe. π
π¦ SYNOPSIS π¦
void __rcu ** radix_tree_next_slot (void __rcu **slot , struct
radix_tree_iter *iter , unsigned flags );
Look at that signature, it's literally iconic. Three arguments, one return, and a whole lot of radix-tree realness. β¨
π ARGUMENTS π
slotβ pointer to current slot. Bestie, this is where you're at right now. Your current location in the chunk. πiterβ pointer to iterator state. This is the main character holding all the context so we know where we've been and where we're going. πflagsβRADIX_TREE_ITER_*, should be constant. Okay so lowkey important: these flags should be constant. We don't be changing them mid-flight, periodt. π©
π₯ RETURN π₯
Pointer to next slot, or NULL if there no more left.
That's it. That's the whole return. If you get a pointer back, slay, keep going. If you get NULL, bestie, you've hit the end and it's time to wrap it up. π«Ά
π DESCRIPTION π
Okay so let me tell you what this function actually does, because it's lowkey doing a lot. π
This function updates iter->index in the case of a successful lookup. Yes bestie, it's mutating your iterator state on the way through β that's just how it is. π
For tagged lookup it also eats iter->tags. Literally eats them. They're consumed, they're gone, they served their purpose and we thank them for their service. π
Now here's the part where it gets a little spicy. There are several cases where slot can be passed in as NULL to this function. And no, that's not a bug β it's a whole vibe that comes from the use of radix_tree_iter_resume or radix_tree_iter_retry. π
In these cases we don't end up dereferencing β and the way that works is:
- a) we are doing tagged iteration and
iter->tagshas been set to 0, or - b) we are doing non-tagged iteration, and
iter->indexanditer->next_indexhave been set up so thatradix_tree_chunk_sizereturns 1 or 0.
So yeah, NULL slot in, no dereference out. The math checks out, the vibes are immaculate, and nobody's crashing today. π§
Bestie do NOT pass a NULL slot unless one of those cases is true. The function is literally telling you the exact conditions, so respect the contract. π
β SEE ALSO β
Okay here's the whole friend group, and honestly they're all linked up and you should probably know them all:
- Kernel file
./include/linux/radix-tree.hstruct radix_tree_iter(9)β the struct itself, the blueprint, the moment Radix-tree synchronization(9)β all about keeping things in syncradix_tree_deref_slot(9)β deref a slotradix_tree_deref_slot_protected(9)β deref a slot but protected, fancyradix_tree_deref_retry(9)β retry the derefradix_tree_exception(9)β the exception handling oneradix_tree_iter_init(9)β get your iterator startedradix_tree_next_chunk(9)β next chunk energyradix_tree_iter_lookup(9)β the lookup oneradix_tree_iter_retry(9)β retry with the iteratorradix_tree_iter_resume(9)β resume where you left offradix_tree_chunk_size(9)β how big is the chunk, bestieradix_tree_for_each_slot(9)β the loop macro for slotsradix_tree_for_each_tagged(9)β the loop macro for tagged stuff
Whole squad is here, iykyk. π
That's the whole page bestie, you ate that. This was radix_tree_next_slot(9) from the Kernel API Manual, sourced from ./include/linux and dated October 2026 β and honestly? Iconic behavior from start to finish. 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