radix_tree_iter_replace(9)
π 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:
radix_tree_find_next_bit(9)radix_tree_shrink(9)__radix_tree_create(9)radix_tree_insert(9)__radix_tree_lookup(9)radix_tree_lookup_slot(9)radix_tree_lookup(9)__radix_tree_replace(9)radix_tree_replace_slot(9)radix_tree_tag_set(9)radix_tree_tag_clear(9)radix_tree_iter_tag_clear(9)radix_tree_tag_get(9)radix_tree_next_chunk(9)radix_tree_gang_lookup(9)radix_tree_gang_lookup_tag(9)radix_tree_gang_lookup_tag_slot(9)radix_tree_iter_delete(9)radix_tree_delete_item(9)radix_tree_delete(9)radix_tree_tagged(9)idr_preload(9)idr_destroy(9)
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
- 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