mas_preallocate(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… mas_preallocate(9) β€” the kernel API manual, bestie edition πŸŽ€

okay so real talk, this one lives in the Kernel API Manual and it's called mas_preallocate β€” and yes it's exactly what it sounds like, it's the "get your nodes ready before the store" girlie ✨


🌸 NAME 🌸

mas_preallocate β€” preallocate enough nodes for a store operation 🫢

like, reserve your space ahead of time so the actual store doesn't have to panic-allocate mid-vibe. iconic planning behavior, honestly πŸ‘‘


✨ SYNOPSIS ✨

int mas_preallocate (struct ma_state *mas , void *entry , gfp_t gfp );

three args, one int back, no cap πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • mas β€” the maple state πŸ“ (yes, the whole struct ma_state *, she's the main character here)
  • entry β€” the entry that will be stored 🌈 like, the thing you're eventually gonna put in there, this call just preps for it
  • gfp β€” the GFP_FLAGS to use for allocations 🌸 so the allocation vibes are entirely your call

πŸ’– RETURN πŸ’–

  • 0 on success β€” slay, you're preallocated πŸŽ‰
  • -ENOMEM if memory could not be allocated 😭 the classic "bestie the allocator said no" moment

πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./lib/maple_tree.c and honestly the whole maple tree friend group, gather round:

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_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), __mt_dup(9), mtree_dup(9), __mt_destroy(9), mtree_destroy(9), mt_find(9), mt_find_after(9) πŸ’œ


ngl the whole maple tree API is a vibe, go read the neighbors, they're all linked above πŸ‘†βœ¨

and that's the page, bestie 🧚 from ./lib, dated October 2026, filed under mas_preallocate(9) β€” go preallocate responsibly, ily, mwah πŸ’‹πŸ’–

πŸ“¦ where this page comes from