STRUCT SBITMAP(9)
π¦ struct sbitmap(9) β the scalable bitmap, bestie edition π
okay so this is a kernel API manual page, section 9, and it's literally all about struct sbitmap, which is a Scalable bitmap. yes that's the whole name. iconic, minimal, slays.
β¨ SYNOPSIS β¨
here's the whole icon in all her glory, copy-paste-exact, no cap:
struct sbitmap {
unsigned int depth;
unsigned int shift;
unsigned int map_nr;
bool round_robin;
struct sbitmap_word *map;
unsigned int __percpu *alloc_hint;
};
π Members π
time for the vibe check on every single field, we're not skipping a one:
depthβ the number of bits used in the whole bitmap. like, the full population. πΈshiftβ literallylog2(number of bits used per word). math girlie behavior.map_nrβ the number of words (cachelines) being used for the bitmap. that's how many chunks we're spread across.round_robinβ when this is set, bits get allocated in strict round-robin order. no favorites, everyone gets a turn. πmapβ the allocated bitmap itself. the actual goods.alloc_hintβ a cache of the last successfully allocated or freed bit. it's giving "remember where I left off" energy.
and about that alloc_hint: this is per-cpu, which allows multiple users to stick to different cachelines until the map is exhausted. so everybody gets their own lane until there's nothing left to hand out. π«Ά
π Description π
A struct sbitmap is spread over multiple cachelines to avoid ping-pong. that's the whole trick, fr fr β it trades off higher memory usage for better scalability. so yeah, she's a little thicc in memory, but she scales beautifully. π₯π
π SEE ALSO π
kernel file ./include/linux/sbitmap.h, plus the whole friend group: struct sbitmap_word(9), struct sbq_wait_state(9), struct sbitmap_queue(9), sbitmap_init_node(9), sbitmap_free(9), sbitmap_resize(9), sbitmap_get(9), sbitmap_any_bit_set(9), __sbitmap_for_each_set(9), sbitmap_for_each_set(9), sbitmap_show(9), sbitmap_weight(9), sbitmap_bitmap_show(9), sbitmap_queue_init_node(9), sbitmap_queue_free(9), sbitmap_queue_recalculate_wake_batch(9), sbitmap_queue_resize(9), __sbitmap_queue_get(9), __sbitmap_queue_get_batch(9), sbitmap_queue_get_shallow(9), sbitmap_queue_get(9), sbitmap_queue_min_shallow_depth(9), sbitmap_queue_clear(9), sbitmap_queue_clear_batch(9), sbq_wait_ptr(9), sbitmap_queue_wake_all(9), sbitmap_queue_wake_up(9), sbitmap_queue_show(9). go read them, iykyk π
ok that's the whole page, no notes, go forth and allocate responsibly π§
and for the cute sign-off: this one's sourced from ./include/linux, dated October 2026 β struct sbitmap(9), that's a wrap bestie ππβ
π¦ 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