roadmap NOT-STARTED

1123. The NVMe driver learns of a completion by interrupt, not by polling

The number, title and slug are provisional. The branch that wrote this block is roadmap/tgoskits-prior-art.

Today both halves of the NVMe path poll. The partsfoundry/non_volatile_memory_express crate leaves the wait to its caller, and its Command::create_io_completion_queue writes IEN=0 and vector 0. The user-space driver in components/src/non_volatile_memory_express_data_plane.rs spins on the phase tag of the completion ring for up to SPIN_BOUND polls, and its admin twin does the same. Each names the polling in its BUGS, and notes/non-volatile-memory-express.md gives the reason: a user-space driver that could aim an MSI had nothing to confine it.

This milestone moves completion to interrupts. The controller signals by MSI-X, one vector per I/O queue pair where the device and the machine offer enough vectors, and by INTx where they do not. The driver sleeps on its interrupt and drains the completion ring when it wakes.

What drives it: a shared machine under load. A spinning data plane burns a core for every command, and the notes already call polling wrong for that case. What it saves: the core the spin holds, and the first step toward more than one command in flight per queue.

Reuse: the kernel's MSI-X and MSI programming in kernel/src/pci.rs (function_interrupt, program_msix, program_msi, intx_intid), the Interrupt capability and its WAIT and ACKNOWLEDGE operations, and the crate's ring arithmetic. It also reuses the VT-d remapping that milestone 1068 (the kernel turns interrupt remapping on where an IOMMU offers it) built. No third-party crate: the prior art below is a design to read, not a dependency.

What reaches a user-space driver today

The kernel already delivers device interrupts to user-space drivers. The virtio-pci transports and the xHCI driver hold an Interrupt capability. WAIT blocks until the line fires, the kernel masks it, and ACKNOWLEDGE unmasks it once the driver has quieted the device.

What is missing

Decisions this milestone needs before it builds

Each of these is a new system call, a new wire surface or a new capability, so each is the architect's. This block recommends none of them.

  1. How a driver receives more than one vector for one function. One Interrupt capability per vector, a capability naming a range, or one capability with a queue index in WAIT's reply.
  2. How a driver waits on a request and a completion together. The options include binding an interrupt to an endpoint (the kernel's bind_interrupt already does this for the progenitor's UART), one thread per queue pair, or a notification object of the seL4 kind.
  3. Who holds the interrupt, the admin process or the data plane, and whether the admin process hands it over as it hands over the doorbell page. The admin queue wants its own vector too.
  4. The crate's new public names for the interrupt-enable flag, the vector argument and the two mask registers. Each ships provisional and goes to a name review.

Prior art

Where nife differs: the kernel owns the MSI-X table and the remapping table, so a driver never programs a vector. It names one only through the capability the kernel granted.

A concrete example. Under QEMU's q35 with intel-iommu and intremap=on, the kernel reserves two vectors for the NVMe function and writes MSI-X entries 0 and 1. It grants the admin process the first and the data plane the second. The data plane rings the submission doorbell, sleeps in WAIT, wakes on vector 1, drains every fresh completion, writes the completion head doorbell and calls ACKNOWLEDGE.

The work, in order

  1. The architect rules the four decisions above.
  2. The crate takes the interrupt-enable flag and the vector in create_io_completion_queue, and names INTMS and INTMC. The work lands in partsfoundry/non_volatile_memory_express through its own queue, and nife's pin moves after it.
  3. The kernel routes the NVMe function's interrupts: as many MSI-X entries as the ruling allows, or INTx where the machine has no MSI. It grants the result in the capabilities the ruling chose.
  4. The admin process creates each I/O completion queue with interrupts enabled and the vector it holds, and the data plane sleeps on its interrupt in place of the spin.
  5. A test that a completion that never comes still ends as EIO, now bounded by a timeout in place of the spin count.

Done when

Follow-on

BUGS

Index row

The NVMe path polls for every completion, which spends a core per command on a loaded machine. This block moves completion to MSI-X with one vector per queue pair, and to INTx where MSI is absent. It names the kernel support that exists and what is missing: more than one vector per function, remapping off VT-d, and a wait on a request and a completion together. The new surface waits on four rulings.