STRUCT INTERVAL_TREE_SPAN_ITER(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ NAME πŸ¦‹

ok so this is a page from the Kernel API Manual (the <kbd>9</kbd> section, iykyk) and it's all about struct interval_tree_span_iter β€” literally its whole job is Find used and unused spans. bestie that's it, that's the vibe πŸ’…


✨ SYNOPSIS ✨

here's the struct, character for character, no cap:

struct interval_tree_span_iter {
    union {
      unsigned long start_hole;
      unsigned long start_used;
    };
    union {
      unsigned long last_hole;
      unsigned long last_used;
    };
    int is_hole;
 };

πŸŽ€ Members πŸŽ€

okay let's meet the cast πŸ‘‘

  • {unnamed_union} β€” anonymous. yes bestie, it has no name, it's mysterious like that πŸ™ˆ
  • start_hole β€” Start of an interval for a hole when is_hole == 1
  • start_used β€” Start of a used interval when is_hole == 0
  • {unnamed_union} β€” anonymous again. two anonymous unions, they're twins 🫢
  • last_hole β€” Inclusive end of an interval for a hole when is_hole == 1
  • last_used β€” Inclusive end of a used interval when is_hole == 0
  • is_hole β€” 0 == used, 1 == is_hole, -1 == done iteration ⭐
tiny note bestie: those last_* fields are inclusive ends, not exclusive. don't come for me, that's just what the page says πŸ’–

🌸 Description 🌸

okay so picture this: this iterator travels over spans in an interval tree πŸ”₯ and here's the plot twist β€” it does not return nodes. instead it classifies each span as either a hole, where no nodes intersect, or a used, which is fully covered by nodes. it's giving main character energy with a whole identity of its own πŸ’€

each iteration step toggles between hole and used until the entire range is covered. and the returned spans? they always fully cover the requested range. always. periodt ✨

also the iterator is greedy πŸ“ β€” it always returns the largest hole or used possible, consolidating all consecutive nodes. it's not here to be subtle, it wants the biggest span and it gets it πŸ‘‘

Use interval_tree_span_iter_done to detect end of iteration. that's your "are we there yet" check, don't skip it 🧚


πŸ’œ SEE ALSO πŸ’œ

  • Kernel file ./include/linux/interval_tree.h

and that's the whole page bestie 🌈 β€” brought to you by ./include/linux, dated October 2026, from the struct inter...ee_span_iter(9) corner of the Kernel API Manual. go forth and iterate, ily πŸ’–πŸ¦‹βœ¨

πŸ“¦ where this page comes from