xa_alloc_cyclic_irq(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… xa_alloc_cyclic_irq πŸ’…

okay so this is the Kernel API Manual's page for xa_alloc_cyclic_irq, and honestly? she's a little baddie. let's get into it bestie 🫢


✨ NAME ✨

xa_alloc_cyclic_irq β€” Find somewhere to store this entry in the XArray. like, she's literally the finder of empty spots. a real estate agent for your XArray, no cap 🏠✨


✨ SYNOPSIS ✨

int xa_alloc_cyclic_irq (struct xarray *xa , u32 *id , void *entry ,
struct xa_limit limit , u32 *next , gfp_t gfp );

look at her. six arguments. main character energy fr πŸ’…


✨ ARGUMENTS ✨

  • xa β€” XArray. the whole vibe, the container, the moment. πŸ—‚οΈ
  • id β€” Pointer to ID. she's a pointer, she points at your ID, that's her job πŸ’–
  • entry β€” New entry. the thing you're sliding into the XArray. fresh off the press ✨
  • limit β€” Range of allocated ID. the boundaries bestie, we stay within them 🌸
  • next β€” Pointer to next ID to allocate. the starting point of the lil search party πŸŽ€
  • gfp β€” Memory allocation flags. the vibe settings for how memory gets grabbed πŸ¦‹

✨ DESCRIPTION ✨

So what she actually does: she finds an empty entry in xa between limit.min and limit.max, stores the index into the id pointer, and then stores the entry at that index. Order matters, and she ate with that ordering β€” a concurrent lookup will not see an uninitialised id. πŸ”₯ no half-finished vibes here.

The search for an empty entry starts at next and will wrap around if necessary. she'll go all the way around the block if she has to, she's not quitting πŸ’€

⚠️ big important caveat bestie: this must only be operated on an xarray initialized with the flag XA_FLAGS_ALLOC set in xa_init_flags. like, that's the whole prerequisite. do not skip it. πŸ™ˆ

also note that callers interested in whether wrapping has occurred should use __xa_alloc_cyclic instead. that's the one with the receipts on wrapping πŸ“


✨ CONTEXT ✨

Process context. Takes and releases the xa_lock while disabling interrupts. May sleep if the gfp flags permit. 😴 so like, she's polite, she locks up properly, and she might nap if you let her. respect.


✨ RETURN ✨

  • 0 β€” if the allocation succeeded. slay πŸŽ‰
  • -ENOMEM β€” if memory could not be allocated. it's giving out-of-memory 😭
  • -EBUSY β€” if there are no free entries in limit. literally no room at the inn πŸ’€

✨ SEE ALSO ✨

Kernel file ./include/linux/xarray.h, plus this entire friend group:

xa_mk_value(9), xa_to_value(9),
xa_is_value(9), xa_tag_pointer(9), xa_untag_pointer(9),
xa_pointer_tag(9), xa_is_zero(9), xa_is_err(9), xa_err(9), struct
xa_limit(9), struct xarray(9), DEFINE_XARRAY_FLAGS(9), DEFINE_XARRAY(9),
DEFINE_XARRAY_ALLOC(9), DEFINE_XARRAY_ALLOC1(9), xa_init_flags(9),
xa_init(9), xa_empty(9), xa_marked(9), xa_for_each_range(9),
xa_for_each_start(9), xa_for_each(9), xa_for_each_marked(9),
xa_store_bh(9), xa_store_irq(9), xa_erase_bh(9), xa_erase_irq(9),
xa_cmpxchg(9), xa_cmpxchg_bh(9), xa_cmpxchg_irq(9), xa_insert(9),
xa_insert_bh(9), xa_insert_irq(9), xa_alloc(9), xa_alloc_bh(9),
xa_alloc_irq(9), xa_alloc_cyclic(9), xa_alloc_cyclic_bh(9),
xa_reserve(9), xa_reserve_bh(9), xa_reserve_irq(9), xa_release(9),
xa_is_sibling(9), xa_is_retry(9), xa_is_advanced(9),
xa_update_node_t(9), XA_STATE(9), XA_STATE_ORDER(9), xas_error(9),
xas_set_err(9), xas_invalid(9), xas_valid(9), xas_is_node(9),
xas_reset(9), xas_retry(9), xas_reload(9), xas_set(9), xas_advance(9),
xas_set_order(9), xas_set_update(9), xas_next_entry(9),
xas_next_marked(9), xas_for_each(9), xas_for_each_marked(9),
xas_for_each_conflict(9), xas_prev(9), xas_next(9)

like, the whole extended family showed up. iconic. πŸ‘‘


and that's the page, bestie 🧚 this one lives in ./include/linux and it's from October 2026, in the Kernel API Manual β€” mwah, go read it again if you need to, i'm obsessed with you for reading the docs fr fr πŸ’œπŸŒˆ

πŸ“¦ where this page comes from