__xa_alloc_cyclic(9)
π __xa_alloc_cyclic β kernel API manual, but make it make sense π
okay bestie, buckle up, because this one is literally the "find a home for my little guy" function and it's lowkey iconic β¨ (it's __xa_alloc_cyclic(9) from the Kernel API Manual, iykyk)
πΈ NAME πΈ
__xa_alloc_cyclic β find somewhere to store this entry in the XArray. that's it, that's the whole vibe π
β¨ SYNOPSIS β¨
int __xa_alloc_cyclic (struct xarray *xa , u32 *id , void *entry ,
struct xa_limit limit , u32 *next , gfp_t gfp );
like, no cap, that's the whole signature π
π«Ά ARGUMENTS π«Ά
xaβ the XArray. your whole little world, bestie π¦idβ pointer to the ID. it's giving "where the answer goes" πentryβ the new entry. the main character we're finding a spot for πlimitβ the range of allocated ID. like a velvet rope at the club, but for indices πnextβ pointer to the next ID to allocate. the starting point of the hunt, fr fr π₯gfpβ memory allocation flags. the little settings that decide how hard we're allowed to try π
π DESCRIPTION π
So here's the tea, bestie π: this function finds an empty entry in xa somewhere between limit.min and limit.max, stores the index into the id pointer, and then stores the entry at that index. the order matters, okay? a concurrent lookup will not see an uninitialised id β slay, no race, no drama β¨
The search for an empty entry starts at next and will wrap around if necessary. it really said "i'll go around the whole thing if i have to" π
okay and this is the important part, do not skip it π β this must only be operated on an xarray initialized with flagXA_FLAGS_ALLOCset inxa_init_flags. like if you skip that, it's not my fault, i warned you π
π§ CONTEXT π§
Any context. yes, ANY. we're flexible like that π
It expects xa_lock to be held on entry. it may release and reacquire xa_lock if the gfp flags permit β so like, it might let go of the lock for a sec and then grab it back, depending on what you allowed it to do. ngl that's kinda iconic π
β RETURN β
0β the allocation succeeded without wrapping. clean, no notes π1β the allocation succeeded after wrapping. it did the extra lap πββοΈ-ENOMEMβ memory could not be allocated π-EBUSYβ there are no free entries inlimit. the door is closed, the club is full, nothing for you here π
π¦ SEE ALSO π¦
kernel file ./lib/xarray.c, plus literally the whole friend group: 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_insert(9), xa_store_range(9), xas_get_order(9), xa_get_order(9), __xa_alloc(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)
π sign-off π
this masterpiece lives in ./lib, dated October 2026, and it's <rainbow>__xa_alloc_cyclic(9)</rainbow> forever and ever, 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