radix_tree_next_slot(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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->tags has been set to 0, or
  • b) we are doing non-tagged iteration, and iter->index and iter->next_index have been set up so that radix_tree_chunk_size returns 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:

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