Skip to content

RFC io_uring dmabuf read/write support

Pavel Begunkov dri-devel io-uring linux-block linux-fsdevel linux-media linux-nvme 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest12 patches 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12file: add callback returning dev for dma operationsinclude/linux/fs.h+2 -00 replies
2/12iov_iter: introduce iter type for pre-registered dmainclude/linux/uio.h lib/iov_iter.c+83 -10 replies
3/12block: move around bio flagging helpersinclude/linux/bio.h+15 -150 replies
4/12block: introduce dmavec bio typeblock/bio.c block/blk-merge.c block/blk.h +3 more+87 -50 replies
5/12block: implement ->get_dma_device callbackblock/bdev.c block/fops.c include/linux/blk-mq.h +1 more+16 -00 replies
6/12nvme-pci: add support for user passed dma vectorsdrivers/nvme/host/pci.c+158 -00 replies
7/12io_uring/rsrc: extended reg buffer registrationinclude/uapi/linux/io_uring.h io_uring/rsrc.c+54 -120 replies
8/12io_uring: add basic dmabuf helpersio_uring/Makefile io_uring/dmabuf.c io_uring/dmabuf.h+95 -00 replies
9/12io_uring/rsrc: add imu flagsio_uring/rsrc.c io_uring/rsrc.h io_uring/rw.c+13 -80 replies
10/12io_uring/rsrc: add dmabuf-backed buffer registerationio_uring/rsrc.c io_uring/rsrc.h+118 -10 replies
11/12io_uring/rsrc: implement dmabuf regbuf importio_uring/rsrc.c io_uring/rsrc.h+61 -80 replies
12/12io_uring/rw: enable dma registered buffersio_uring/rw.c+2 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC 00/12] io_uring dmabuf read/write support

Disclaimer: haven't been tested well enough yet and needs more beating

For past couple of months David Wei, Vishal Verma and other folks have been mentioning that it'd be great to have dmabuf support for read/write and other operations in io_uring. The topic is not new, it has been discussed many times in different contexts including networking. The last relevant attempt was premapped dma tags by Keith [1], and this patch set took a lot from it.

This series implements it for read/write io_uring requests. The uAPI looks similar to normal registered buffers, the user will need to register a dmabuf in io_uring first and then use it as any other registered buffer. On registration the user also specifies a file to map the dmabuf for.

// register
io_uring_update_buffers(ring, { dma_buf_fd, target_file_fd }); // use
reg_buf_idx = 0;
io_uring_prep_read_fixed(sqe, target_file_fd, buffer_offset,

                         buffer_size, file_offset, reg_buf_idx);

It's an RFC to discuss the overall direction. The series misses parts like bio splitting and nvme sgl support, and otherwise there are some rough edges and probably problems, which will need more testing and attention.

[1] https://lore.kernel.org/io-uring/[email protected]/

simple liburing based example:
git: https://github.com/isilence/liburing.git dmabuf-rw

kernel branch:
git: https://github.com/isilence/linux.git dmabuf-rw-v1

Pavel Begunkov (12):
file: add callback returning dev for dma operations
iov_iter: introduce iter type for pre-registered dma
block: move around bio flagging helpers
block: introduce dmavec bio type
block: implement ->get_dma_device callback
nvme-pci: add support for user passed dma vectors io_uring/rsrc: extended reg buffer registration
io_uring: add basic dmabuf helpers io_uring/rsrc: add imu flags
io_uring/rsrc: add dmabuf-backed buffer registeration io_uring/rsrc: implement dmabuf regbuf import io_uring/rw: enable dma registered buffers

 block/bdev.c                  |  11 ++
 block/bio.c                   |  21 ++++
 block/blk-merge.c             |  32 +++++
 block/blk.h                   |   2 +-
 block/fops.c                  |   3 +
 drivers/nvme/host/pci.c       | 158 +++++++++++++++++++++++
 include/linux/bio.h           |  59 ++++++---
 include/linux/blk-mq.h        |   2 +
 include/linux/blk_types.h     |   6 +-
 include/linux/blkdev.h        |   2 +
 include/linux/fs.h            |   2 +
 include/linux/uio.h           |  14 +++
 include/uapi/linux/io_uring.h |  13 +-
 io_uring/Makefile             |   1 +
 io_uring/dmabuf.c             |  60 +++++++++
 io_uring/dmabuf.h             |  34 +++++
 io_uring/rsrc.c               | 230 ++++++++++++++++++++++++++++++----
 io_uring/rsrc.h               |  23 +++-
 io_uring/rw.c                 |   7 +-
 lib/iov_iter.c                |  70 ++++++++++-
 20 files changed, 701 insertions(+), 49 deletions(-)
 create mode 100644 io_uring/dmabuf.c
 create mode 100644 io_uring/dmabuf.h
Signature · 1 line
2.49.0