xas_nomem(9)
π xas_nomem(9) π
ok so this is a page from the Kernel API Manual, and today's main character is xas_nomem β she's the "bestie, can you grab me some memory real quick" helper for the XArray. Let's get into it π
β¨ NAME β¨
xas_nomem β allocate memory if needed. literally that's it, that's her whole job π
πΈ SYNOPSIS πΈ
bool xas_nomem (struct xa_state *xas , gfp_t gfp );
π¦ ARGUMENTS π¦
xasβ the XArray operation state. this is the girl holding all the context, she's been through a lot π«Άgfpβ the memory allocation flags. the vibes you pass along to the allocator, basically β¨
π DESCRIPTION π
okay so picture this: we need to add new nodes to the XArray, right? while we're holding the lock, we try to allocate memory with GFP_NOWAIT, and ngl it usually slays and just works π
but if it fails β and sometimes it does, it's giving "not today" π β then xas gets flagged as needing memory to continue. that's your cue, bestie: the caller should drop the lock and call xas_nomem. and if xas_nomem succeeds? retry the operation. periodt π₯
forward progress is guaranteed here, because exactly one node gets allocated at this point and stored in the xa_state, where xas_alloc will find it later. iconic behavior honestly π
more nodes will likely be sitting around in the slab allocator, but we do not tie them up here β we're not doing all that, not today π
β RETURN β
true if memory was needed, and was successfully allocated. that's the whole deal π
π SEE ALSO π
Kernel file ./lib/xarray.c β plus the whole friend group, and yes we're listing every single one of them, no skipping π
xas_load(9)xas_free_nodes(9)xas_create_range(9)xas_store(9)xas_get_mark(9)xas_set_mark(9)xas_clear_mark(9)xas_init_marks(9)xas_split_alloc(9)xas_split(9)xas_try_split_min_order(9)xas_try_split(9)xas_pause(9)xas_find(9)xas_find_marked(9)xas_find_conflict(9)xa_load(9)__xa_erase(9)xa_erase(9)__xa_store(9)xa_store(9)__xa_cmpxchg(9)__xa_insert(9)xa_store_range(9)xas_get_order(9)xa_get_order(9)__xa_alloc(9)__xa_alloc_cyclic(9)__xa_set_mark(9)__xa_clear_mark(9)xa_get_mark(9)xa_set_mark(9)xa_clear_mark(9)xa_find(9)xa_find_after(9)xa_extract(9)xa_delete_node(9)xa_destroy(9)
bestie reminder: if memory was needed and you got it, retry the operation. don't just sit there π
πΈ that's the whole page!! brought to you by ./lib, dated October 2026 β mwah, go forth and allocate responsibly πβ¨π
π¦ 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