STRUCT SBITMAP(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ 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 β€” literally log2(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