xa_extract(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– xa_extract(9) β€” the group-chat guide πŸ’–

okay bestie, welcome to the Kernel API Manual, section 9, and today's main character is xa_extract. no cap, this one's genuinely a vibe. ✨


🌸 NAME 🌸

xa_extract β€” literally copies the entries you picked out of the XArray and drops them into a normal array. that's it, that's the whole gig. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

unsigned int xa_extract (struct xarray *xa , void **dst , unsigned long
start , unsigned long max , unsigned int n , xa_mark_t filter );

⭐ ARGUMENTS ⭐

  • xa β€” the source XArray you're copying from. your origin story, if you will. πŸ’œ
  • dst β€” the buffer everything gets copied into. the destination, the glow-up location. 🫢
  • start β€” the first index in the XArray that's even eligible to be selected. lower bound, bestie. πŸ“
  • max β€” the last index in the XArray eligible to be selected. upper bound, the cutoff. 🌸
  • n β€” the maximum number of entries to copy. like a guest list with a capacity, respectfully. πŸŽ€
  • filter β€” the selection criterion. who gets in, who doesn't. the bouncer, basically. πŸ’…

✨ DESCRIPTION ✨

so here's the teaaa: it copies up to n entries that match filter from the XArray, and the copied entries will have indices between start and max, inclusive. inclusive is the key word there, don't forget it. 🌈

the filter can be an XArray mark value β€” in which case, entries that are marked with that mark get copied. it can also be XA_PRESENT, in which case all the entries that are not NULL get copied. simple as that. πŸ’–

🫢 important vibe check: the entries returned may not represent a snapshot of the XArray at a moment in time. lowkey the most important sentence on this whole page, ngl.

like, for example: if another thread stores to index 5, then index 10, calling xa_extract may return the old contents of index 5 and the new contents of index 10. it's giving "mixed eras" 😭. the good news though β€” indices not modified while this function is running will not be skipped. so nothing gets ghosted. πŸ’€

if you need stronger guarantees, holding the xa_lock across calls to this function will prevent concurrent modification. that's the secure-the-bag move. πŸ‘‘


πŸ”₯ CONTEXT πŸ”₯

any context, queen. it takes and releases the RCU lock. that's it. 🌟


πŸ‘‘ RETURN πŸ‘‘

the number of entries copied. that's the whole return value, no plot twist. πŸŽ€


πŸ’« SEE ALSO πŸ’«

kernel file ./lib/xarray.c, plus the whole extended 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_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_delete_node(9), xa_destroy(9)


k byeee, this page came from ./lib, dated October 2026 β€” mwah, slay, periodt πŸ’…βœ¨

πŸ“¦ where this page comes from