summaryrefslogtreecommitdiff
path: root/io_uring/dma-buf.c
AgeCommit message (Collapse)Author
9 daysio_uring/dma-buf: allow cloning registered dma-bufsPavel Begunkov
One problem that was brought up is that the file table size is often a limiting factor when working with dma-bufs, which is quite an old problem. With a single io_uring people can work it around by closing the dma-buf fd after registration, but for more complex cases we need a way to dynamically register it into another ring. We also need to deduplicate internal registrations as each creates a new attachment and related structures, which could involve large allocations and iommu mappings. Solve it by enabling io_uring buffer cloning. I made dma-bufs registered for io_uring not cloneable between rings because the implementation could modify parts of struct io_buf_dma without any locking and sharing it would've created races. That was an optimisation that got dropped at some point for simplicity, so we can safely enable cloning back as long as IORING_SETUP_IOPOLL rejection is honoured. Kill the uncloneable flag as unused as well. Reported-by: William Power <william.power@intel.com> Reported-by: Tushar Gohad <tushar.gohad@intel.com> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://patch.msgid.link/b76cf21ee0e2362489c864e43781b20d95fd75f7.1792142588.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
11 daysio_uring/rsrc: add dmabuf backed registered buffersPavel Begunkov
Implement dmabuf backed registered buffers. To register them, the user should specify IO_REGBUF_TYPE_DMABUF for the regitration and pass the desired dmabuf fd and a file for which it should be registered. >From there, it can be used with io_uring read/write requests IORING_OP_{READ,WRITE}_FIXED) as normal. The requests should be issued against the file specified during registration, and otherwise they'll be failed. The user should also be prepared to handle spurious -EAGAIN by reissuing the request. Internally, dmabuf registered buffers is an optin feature for io_uring request opcodes and they should pass a special flag on import to use it. Suggested-by: David Wei <dw@davidwei.uk> Suggested-by: Vishal Verma <vishal1.verma@intel.com> Suggested-by: Tushar Gohad <tushar.gohad@intel.com> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://patch.msgid.link/4aa230df871ee275536f367087b44ebfebb88cc1.1791975048.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>