bitmap_find_free_region(9)
π bitmap_find_free_region(9) π
okay so this is a page from the Kernel API Manual, and bestie, it's literally about grabbing a nice lil chunk of free space out of a bitmap. it's bitmap_find_free_region, and yes she's iconic π
β¨ NAME β¨
bitmap_find_free_region β find a contiguous aligned mem region π
πΈ SYNOPSIS πΈ
int bitmap_find_free_region (unsigned long *bitmap , unsigned int bits ,
int order );
like, that's the whole signature. short king π«Ά
π¦ ARGUMENTS π¦
bitmapβ the array ofunsigned longs that correspond to the bitmap. this is the thing you're hunting through, no cap.bitsβ how many bits are in the bitmap, fr fr. that's your total playing field.orderβ the region size you wanna find, expressed as log base 2 of the number of bits. soorderis giving "the exponent, not the answer" π
π« DESCRIPTION π«
so what she does is: find a region of free (zero) bits in a bitmap of bits bits, and then allocate them by setting them to one. periodt. π
and here's the slay part β she only considers regions of length a power (order) of two, aligned to that power of two. the way that makes the search algorithm much faster?? obsessed. β‘ highkey a vibe.
so yeah, aligned-only. that's not a bug, that's the whole point of the speed. don't come for her π
π RETURN π
returns the bit offset in bitmap of the allocated region π β or -errno on failure π (yes, negative errno, watch out for it).
π₯ SEE ALSO π₯
kernel file ./include/linux/bitmap.h π§
- bitmap overview(9)
- bitmap bitops(9)
- declare bitmap(9)
- bitmap_find_next_zero_area(9)
- bitmap_or_equal(9)
- bitmap_weight_from(9)
- bitmap_scatter(9)
- bitmap_gather(9)
- bitmap_release_region(9)
- bitmap_allocate_region(9)
BITMAP_FROM_U64(9)- bitmap_from_u64(9)
- bitmap_read(9)
- bitmap_write(9)
π okay that's the whole page, bestie! this one's brought to you from ./include/linux, October 2026, and it's bitmap_find_free_region(9) signing off β mwah πβ¨
π¦ 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