ida_alloc_range(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– ida_alloc_range(9) β€” a Kernel API Manual moment πŸ’–

okay bestie, welcome to the Kernel API Manual, and today's main character is ida_alloc_range ✨ she's literally here to hand you an unused ID and she eats every time πŸ’…


🌸 NAME 🌸

ida_alloc_range β€” allocate an unused ID, no cap 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹

int ida_alloc_range (struct ida *ida , unsigned int min , unsigned int max , gfp_t gfp );

πŸŽ€ ARGUMENTS πŸŽ€

  • ida β€” your IDA handle, like her little backstage pass πŸ’–
  • min β€” the lowest ID to allocate, the floor, the bare minimum, periodt
  • max β€” the highest ID to allocate, the ceiling, the limit, the "don't even try it" ✨
  • gfp β€” memory allocation flags, the whole vibe check for how memory gets grabbed 🧚

πŸ’… DESCRIPTION πŸ’…

So here's the tea: this function allocates an ID between min and max, inclusive β€” both ends are invited to the party πŸŽ‰ The allocated ID will not exceed INT_MAX, even if max is larger. Like, she said "I'm not going past INT_MAX, bestie, don't test me" πŸ’€


🌈 CONTEXT 🌈

Any context. It is safe to call this function without locking in your code, so you can literally just call her β€” no lock needed, no stress, main character energy only πŸ‘‘βœ¨


⭐ RETURN ⭐

  • The allocated ID β€” slay, you got one πŸ’–
  • -ENOMEM if memory could not be allocated 😭
  • -ENOSPC if there are no free IDs πŸ™ˆ

πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./lib/idr.c β€” and the whole friend group:


lowkey if you're out here allocating IDs, remember: min and max are inclusive, and INT_MAX is the final boss you cannot pass 🫢

mwah πŸ’‹ huge kiss to ./lib for bringing us this iconic function, dated October 2026 β€” catch you in the next manpage, bestie! πŸŽ€πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from