mas_alloc_cyclic(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🍁 mas_alloc_cyclic(9) 🍁

okay so bestie, real talk: this is the Kernel API Manual page for mas_alloc_cyclic, and it's literally the internal call that goes "hiiii where do I put this entry πŸ’…". It's the Maple Tree's little matchmaker for finding somewhere to store an entry. Periodt.


✨ NAME ✨

mas_alloc_cyclic β€” Internal call to find somewhere to store an entry

like, it's not the public-facing bestie, it's the internal one. iykyk.


πŸŽ€ SYNOPSIS πŸŽ€

int mas_alloc_cyclic (struct ma_state *mas , unsigned long *startp ,
void *entry , unsigned long range_lo , unsigned long range_hi , unsigned
long *next , gfp_t gfp );

no cap, that's the whole signature. don't touch a single character of it πŸ™ˆ


πŸ¦‹ ARGUMENTS πŸ¦‹

okay the vibe check on every single parameter, one by one, because we do not skip:

  • mas β€” The maple state. this is the main character of the whole operation, fr.
  • startp β€” Pointer to ID. it points at where the ID lives πŸ’–
  • entry β€” The entry to store. the actual thing we're putting in, iconic.
  • range_lo β€” Lower bound of range to search. the floor of the search zone.
  • range_hi β€” Upper bound of range to search. the ceiling of the search zone.
  • next β€” Pointer to next ID to allocate. yes hello, next in line please 🌸
  • gfp β€” The GFP_FLAGS to use for allocations. the allocation energy, if you will ✨

πŸ”₯ RETURN πŸ”₯

it returns an int, and here's how to read the results, bestie:

  • 0 β€” the allocation succeeded without wrapping. clean run, no drama. slay 🫢
  • 1 β€” the allocation succeeded after wrapping. it looped around and still came through. resilient queen πŸ‘‘
  • -EBUSY β€” there are no free entries. fully booked, nothing available, it's giving sold out 😭
no third option, no vibes-based guessing β€” those are the only three outcomes, so check your return value properly πŸ’€

🌈 SEE ALSO 🌈

Kernel file ./lib/maple_tree.c, and literally the entire extended friend group of functions:

that's the whole group chat, everyone invited πŸ’œ


ngl, this one's internal β€” so if you're reading it, you're either deep in ./lib/maple_tree.c or you're just curious. either way, proud of you 🧚

okay that's the page!! πŸ’– this lil number lives in ./lib, drops in October 2026, and goes by mas_alloc_cyclic(9) β€” catch you in the source, bestie, mwah πŸŽ€β­

πŸ“¦ where this page comes from