STRUCT BLK_STAT_CALLBACK(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– struct blk_stat_callback(9) πŸ’–

okay so this is the Kernel API Manual, and today’s main character is struct blk_stat_callback β€” block stats callback representation, no cap ✨

✨ NAME ✨

struct blk_stat_callback β€” Block statistics callback. That’s the whole name section bestie, short and iconic πŸ’…

✨ SYNOPSIS ✨

       struct blk_stat_callback {
           struct list_head list;
           struct timer_list timer;
           struct blk_rq_stat __percpu *cpu_stat;
           int (*bucket_fn)(const struct request *);
           unsigned int buckets;
           struct blk_rq_stat *stat;
           void (*timer_fn)(struct blk_stat_callback *);
           void *data;
           struct rcu_head rcu;
        };

That’s the struct, laid out exactly like that β€” copy it, respect it, don’t freestyle it 🫢

🫢 Members 🫢

  • list β€” the RCU list of callbacks for a struct request_queue.
  • timer β€” the timer for the next callback invocation ⏰
  • cpu_stat β€” the per-cpu statistics buckets πŸ“
  • bucket_fn β€” given a request, returns which statistics bucket it should be accounted under; return -1 for no bucket for this request.
  • buckets β€” the number of statistics buckets.
  • stat β€” the array of statistics buckets.
  • timer_fn β€” the callback function.
  • data β€” a private pointer for the user.
  • rcu β€” the rcu list head.

🌸 Description 🌸

Here’s the tea: a struct blk_stat_callback is associated with a struct request_queue πŸ‘‘

While timer is active, that queue’s request completion latencies are sorted into buckets by bucket_fn and added to a per-cpu buffer, cpu_stat. When the timer fires, cpu_stat is flushed to stat and timer_fn is invoked. Literally the whole flow, and it ate πŸ”₯

πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./block/blk-stat.h β€” also go read blk_stat_alloc_callback(9), blk_stat_add_callback(9), blk_stat_remove_callback(9), blk_stat_free_callback(9), blk_stat_is_active(9), blk_stat_activate_nsecs(9), and blk_stat_activate_msecs(9) πŸ’–


source/version: ./block Β· date: October 2026 Β· page: struct blk_stat_callback(9) β€” signing off with maximum main character energy, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from