mas_erase(9)
π mas_erase(9) β the kernel API manual, but make it cute πΈ
okay so bestie, welcome to the mas_erase(9) page from the Kernel API Manual. buckle up, this one's short but it's got lore.
β¨ NAME β¨
mas_erase β finds the range that index lives in and then, yeah, erases the entire range. like not just a little bit. the whole thing. π
π¦ SYNOPSIS π¦
void * mas_erase (struct ma_state *mas );
π ARGUMENTS π
masβ the maple state π (yes, that's its name, and yes, it's the main character here)
π DESCRIPTION π
okay so first things first: you must hold the write lock. not optional, not "later", not "i'll get to it". lock it up π
It searches for mas->index, sets mas->index and mas->last to the range, and erases that range. periodt. β¨
ngl here's the part you actually need to know: erase requires allocations, and it will use GFP_KERNEL | __GFP_NOFAIL to do so if it needs to. if the allocation fails, the internal lock gets dropped to retry. so if your tree is externally locked, it has to be protected by a lock that allows blocking for this API. no cap. π
π RETURN π
It returns the entry that was erased, or NULL. either way, mas->index and mas->last get updated. π«Ά
π SEE ALSO π
Kernel file ./lib/maple_tree.c, plus the whole friend group:
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_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), __mt_dup(9), mtree_dup(9), __mt_destroy(9), mtree_destroy(9), mt_find(9), mt_find_after(9)
that's the whole page, bestie π this drop is from ./lib, dated October 2026 β take care of her, she's iconic πβ¨
π¦ 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