radix_tree_iter_replace(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… radix_tree_iter_replace β€” bestie's guide to swapping items in a slot

okay so this is a page from the Kernel API Manual, and it's about radix_tree_iter_replace β€” the function that swaps out whatever's sitting in a slot while you're iterating. it's giving "surgical little swap" and honestly? iconic πŸŽ€


✨ SYNOPSIS ✨

void radix_tree_iter_replace (struct radix_tree_root *root , const
struct radix_tree_iter *iter , void __rcu **slot , void *item );

like, five things going on in that signature and every one of them matters, no cap πŸ’…


🌸 ARGUMENTS 🌸

  • root β€” the radix tree root. your tree. the whole vibe starts here 🌳
  • iter β€” iterator state. it's holding the place in the walk for you 🫢
  • slot β€” pointer to the slot. like, the actual address of the thing you're touching πŸ“
  • item β€” the new item to store in the slot. the glow-up ✨

πŸ¦‹ DESCRIPTION πŸ¦‹

so this one is for use with radix_tree_for_each_slot. that's the whole reason it exists, fr fr β€” it's the replace call that lives inside that loop.

πŸ’€ the caveat, and do not skip this one: the caller must hold the tree write locked. not read. not "eh, probably fine." write locked. iykyk, but like, actually know it 😭

πŸ‘‘ SEE ALSO πŸ‘‘

kernel file ./lib/radix-tree.c β€” that's the source, go read it, it's a whole journey πŸ“–

and the family reunion of related functions, all of them, in order:

like, that's the whole friend group, they all show up 🫢


and that's the page, bestie! 🌈 sign-off time: this one comes from ./lib, dated October 2026 β€” screenshot it, pin it, live by it πŸ’–πŸŽ€πŸŒΈ

πŸ“¦ where this page comes from