__mt_dup(9)
β¨ __mt_dup β section 9 kernel API, bestie edition β¨
okay so this is __mt_dup from the kernel API manual (section 9, the kernel-space girlies π
), and it's literally the glow-up button for an entire maple tree. let's get into it π
πΈ SYNOPSIS πΈ
int __mt_dup (struct maple_tree *mt , struct maple_tree *new , gfp_t gfp
);
three args, one int back, no cap π
π¦ ARGUMENTS π¦
mtβ the source maple tree, aka the one you're copying from πnewβ the new maple tree, aka the destination glow-up πgfpβ theGFP_FLAGSyou wanna use for allocations, so pick your flags wisely bestie π
π DESCRIPTION π
so the way this works: it duplicates a maple tree in Depth-First Search (DFS) pre-order traversal. it uses memcpy to copy nodes in the source tree and allocates new child nodes in non-leaf nodes. the new node is exactly the same as the source node except for all the addresses stored in it β the way that's efficient fr fr π
it will be faster than traversing all elements in the source tree and inserting them one by one into the new tree. ate and left no crumbs π₯
β οΈ bestie, ground rules: the user needs to ensure that the attributes of the source tree and the new tree are the same, and the new tree needs to be an empty tree, otherwise -EINVAL will be returned. also note that the user needs to manually lock the source tree and the new tree. no auto-locking here, you're on your own π
β RETURN β
0on success β slay β¨-ENOMEMif memory could not be allocated π-EINVALif the attributes of the two trees are different or the new tree is not an empty tree π
π«Ά SEE ALSO π«Ά
the whole friend group, no one left out π Kernel file ./lib/maple_tree.c, plus 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), mt_next(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), mtree_dup(9), __mt_destroy(9), mtree_destroy(9), mt_find(9), mt_find_after(9) π
π§ and that's the page! brought to you by./lib, circa October 2026, filed under__mt_dup(9)β 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