xa_find(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… xa_find β€” the Kernel API Manual, section 9, bestie edition ✨

okay so we're doing xa_find(9) today and honestly? she's iconic. this is the XArray girlies' entry point for finding stuff, and i'm gonna walk you through it like we're texting at 2am 🫢


🌸 SYNOPSIS 🌸

void * xa_find (struct xarray *xa , unsigned long *indexp , unsigned long max , xa_mark_t filter );

four arguments, one pointer back out, no cap. let's get into it πŸ’–


πŸŽ€ ARGUMENTS πŸŽ€

  • xa β€” bestie. it's the XArray. the whole vibe lives in here ✨
  • indexp β€” a pointer to an index. not the index itself, the pointer, okay? important. she's getting updated later, we'll get there πŸ‘€
  • max β€” the maximum index to search to. like a "do not pass go" line but for indices 🚧
  • filter β€” the selection criterion. this is the vibe check β€” what you're actually looking for πŸ’…

⭐ DESCRIPTION ⭐

so here's the tea β˜• β€” xa_find finds the entry in xa that matches the filter, and it picks the one with the lowest index that is at least indexp and no more than max. basically: the smallest eligible baddie in your range, first come first served πŸ‘‘

if it does find an entry, it updates indexp to be the index of that entry. yes, it writes back through your pointer. that's the whole reason it's a pointer, iykyk πŸ”₯

⚠️ heads up: this function is protected by the RCU read lock, so it may not find entries which are being simultaneously added β€” if somebody's mid-insert, she simply didn't see it. no drama, that's just how she runs 😭

and another thing β€” she will not return an XA_RETRY_ENTRY. not her job, not her problem. if you need to see retry entries, use xas_find instead. different girl, different energy πŸ’€


πŸ¦‹ CONTEXT πŸ¦‹

any context. literally any. she takes and releases the RCU lock herself, so she's low maintenance like that 🌈


πŸ’œ RETURN πŸ’œ

the entry, if found. otherwise NULL. that's it. that's the whole return section. short and slay πŸŽ€


🧚 SEE ALSO 🧚

kernel file ./lib/xarray.c β€” and honestly the whole xarray extended universe, all of it, right here bestie:

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_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_after(9), xa_extract(9), xa_delete_node(9), xa_destroy(9)

like. that's a whole friend group. go say hi πŸ’–


mwah πŸ’‹ this has been ./lib (the kernel API manual, section 9), version dated October 2026. go find your entry bestie, you got this πŸ‘‘βœ¨

πŸ“¦ where this page comes from