IDA DESCRIPTION(9)
π IDA description π
okay bestie, this is the IDA description page from the Kernel API Manual, section 9 β and itβs giving tiny but mighty allocator energy. β¨
So the IDA is an ID allocator, and the big thing it does not do is give you the ability to associate an ID with a pointer. Because of that, it only needs to store one bit per ID β literally one bit β so itβs more space efficient than an IDR. Memory queen behavior, fr fr. π
To use an IDA, define it using DEFINE_IDA (or embed a struct ida in a data structure, then initialise it using ida_init). To allocate a new ID, call ida_alloc, ida_alloc_min, ida_alloc_max or ida_alloc_range. To free an ID, call ida_free. Slay. π
ida_destroy can be used to dispose of an IDA without needing to free the individual IDs in it. You can use ida_is_empty to find out whether the IDA has any IDs currently allocated. Cute and useful. π
The IDA handles its own locking. It is safe to call any of the IDA functions without synchronisation in your code. No cap β no extra lock choreography needed in your code. πβ¨
IDs are currently limited to the range [0-INT_MAX]. If this is an awkward limitation, it should be quite straightforward to raise the maximum.
π¦ SEE ALSO π¦
Kernel file ./lib/idr.c and the whole reference squad:
idr_alloc_u32(9)idr_alloc(9)idr_alloc_cyclic(9)idr_remove(9)idr_find(9)idr_for_each(9)idr_get_next_ul(9)idr_get_next(9)idr_replace(9)ida_alloc_range(9)ida_find_first_range(9)ida_free(9)ida_destroy(9)
okay bye bestie π mwah β source/version: ./lib; date: October 2026. π«ΆπΈ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms