Linux blk-mq
Linux blk-mq is the block-layer mechanism that stages and dispatches I/O through multiple software and hardware queues.
Software staging can support merging and I/O scheduling before requests reach hardware dispatch queues. Selecting the none scheduler does not bypass the complete kernel block layer. [1]
Staging queues are defined per CPU or per node, each with its own lock. The number of hardware dispatch queues follows the hardware contexts of the device and driver but does not exceed the number of cores. Requests that cannot be sent immediately wait on a dispatch list served first on the next queue run. [1]
Queue topology alone does not provide a per-application latency guarantee. Neither the block layer nor the device protocol guarantees completion order, so higher layers must enforce required dependencies. [1]
Linux v6.16 can attempt plug merging and request-QoS throttling before scheduler insertion. These operations can remain with none selected. A plug is flushed at 32 requests, or 64 across multiple queues, or when its last request reaches 128 KiB on a merging queue. mq-deadline shares sorting and FIFO state across its hardware queues. [3] [5] [4]
Tag allocation is distinct from dispatch. In Linux v6.16, scheduler-tagged requests initially have internal_tag but no driver tag; without a scheduler, tag is assigned at allocation. The request timer starts in blk_mq_start_request, not merely when a tag exists. [3]
Relations
- related
- NVMe, Queue depth, Inter-flow interference, io_uring, I/O scheduler, mq-deadline, Budget Fair Queueing (BFQ), Kyber I/O scheduler, blk-mq request tag, Head-of-line blocking
Advantages
- CPU-local submission entry points remove the single shared queue lock that limited scaling on multiprocessor systems. [1]
Limitations
- Merging adjacent sectors happens in staging, and there is no reordering at the hardware dispatch stage. [1]
Citations
- Linux kernel documentation: Multi-Queue Block IO Queueing Mechanism, operation, schedulers and hardware dispatch queues.
- Linux v6.16: blk-mq.c, blk_mq_submit_bio
- Linux v6.16: mq-deadline.c, soft expirations and dd_dispatch_request
- Linux v6.16: block/blk.h, BLK_MAX_REQUEST_COUNT and BLK_PLUG_FLUSH_SIZE
Further reading
Sources & caveats
- blk-mq is the Linux 6.16 multi-queue block I/O page, re-read for staging queues, hardware queue counts and the dispatch list.
- blk-h is the v6.16 block/blk.h header, read for BLK_MAX_REQUEST_COUNT and BLK_PLUG_FLUSH_SIZE.
- blk-source and deadline are the v6.16 blk-mq.c and mq-deadline.c sources, re-read on git.kernel.org at the same tag.
- The io-request-size entry links here because plug merging can turn several submitted requests into one larger device request.