__xa_insert(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… __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 expects xa_lock to be held on entry. Also, if the gfp flags permit it, it may release and reacquire xa_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:


πŸŽ€ 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