__xa_insert(9)
π
__xa_insert β the "only if nobody's home" store π
Okay bestie, so this page is __xa_insert(9) from the kernel API manual, and it's lowkey the XArray function you reach for when you want to claim a slot but absolutely refuse to clobber anything that's already there. Iconic behaviour, honestly. π
β¨ SYNOPSIS β¨
int __xa_insert (struct xarray *xa , unsigned long index , void *entry ,
gfp_t gfp );
π«Ά ARGUMENTS π«Ά
xaβ the XArray. your array. your main character. πindexβ the index into the array β i.e. where you're parking this thing.entryβ the new entry, the whole point of the operation β¨gfpβ the memory allocation flags. the vibes you're allocating with.
πΈ DESCRIPTION πΈ
So here's the tea, bestie: if you hand this thing a NULL entry, it stores a reserved entry (exactly like xa_reserve does) β but only if there's no entry present already. No cap. π§
And the plot twist: if a reserved entry is already sitting there, the insert will fail, even though loading from that index still returns NULL. Yeah. It looks empty, it reads as NULL, but the insert says nope β that slot is spoken for. π
π¦ CONTEXT π¦
Any context, bestie β it's flexible like that. π
β οΈ But it expectsxa_lockto be held on entry. Also, if thegfpflags permit it, it may release and reacquirexa_lock. So don't go assuming your lock is still exactly how you left it. π
β RETURN β
0β the store succeeded. slay. we ate. π₯-EBUSYβ another entry was present. somebody's already in that seat, bestie. π-ENOMEMβ memory could not be allocated. the budget said no. π
π SEE ALSO π
It's giving "I have a friend group and it's the entire XArray implementation", so here's the full roster from the kernel file ./lib/xarray.c β in order, because we respect the lineup:
xas_load(9)xas_nomem(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_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)
π the sign-off π
That's the whole page, bestie β shipped out of ./lib, dated October 2026. Go forth and insert responsibly, and remember: lock held, entry checked, vibes immaculate. πβ¨π¦
π¦ 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