본문 바로가기

Computer System/Kernel

[Block I/O Layer] 5. I/O queueing (blk-mq)

I/O queueing (blk-mq)

- request가 block layer에 도달했을 시 hardware dispatch queue로 바로 전달되거나 software staging queue로 전달됨

- Software staging queue로 전달되는 경우는 두가지

  1. I/O scheduler가 설정되어 있을 때
  2. request를 merge해야 할 때

- Software staging queue를 거친 request는 그 후 hardware dispatch queue로 전달

- Hardware에 충분한 리소스가 없을 시 temporary queue에 임시로 저장

- Device driver는 hardware dispatch queue를 사용해 각 block device들의 submission queue로 매핑

 

Figure 1. blk-mq mapping case

 

Submission queue & Completion queue (NVMe device)

 

- Submission queue는 64-byte command structure의 배열과 두개의 integer (head & tail)로 이루어짐

- Completion queue는 16-byte completion structure의 배열과 두개의 integer (head & tail)로 이루어짐

- 각 queue마다 doorbell이라고 불리는 32-bit register들이 존재

Figure 2. NVMe device driver submission & completion queue

 

- NVMe driver에 request가 전달 될 시 다음과 같은 순서로 queueing을 진행

  1. request가 device로 전달 될 시 64-byte의 command structure를 형성해 submission queue의 tail로 전달
  2. Submissions queue의 doorbell에 새로운 tail을 기록
  3. Command structure를 fetch/process
  4. 16-byte의 completion structure를 형성해 completion queue의 tail로 전달
  5. Completion queue의 head index를 가진 interrupt를 생성
  6. Head부터 completion structure을 process
  7. 새로운 head를 completion queue doorbell에 기록

 

 

 

 

 

출처:

https://www.kernel.org/doc/html/v5.11/block/blk-mq.html

 

Multi-Queue Block IO Queueing Mechanism (blk-mq) — The Linux Kernel documentation

The block IO subsystem adds requests in the software staging queues (represented by struct blk_mq_ctx) in case that they weren’t sent directly to the driver. A request is one or more BIOs. They arrived at the block layer through the data structure struct

www.kernel.org

https://spdk.io/doc/nvme_spec.html

 

SPDK: Submitting I/O to an NVMe Device

The NVMe Specification The NVMe specification describes a hardware interface for interacting with storage devices. The specification includes network transport definitions for remote storage as well as a hardware register layout for local PCIe devices. Wha

spdk.io