io_uring provided buffers
io_uring provided buffers are application-supplied buffers grouped for kernel selection by supported I/O requests.
Selection: IOSQE_BUFFER_SELECT and buf_group choose a supplied group. Supported read or receive requests select a destination; supported sends can instead select outgoing data. If IORING_CQE_F_BUFFER is set, the upper 16 CQE flag bits give the application buffer ID, not a fixed-buffer index. [1] [10] [11]
Ring publication: io_uring_buf_ring_add writes a descriptor; io_uring_buf_ring_advance publishes previously added descriptors for kernel consumption. The insertion offset is relative to the ring tail, not the application buffer ID. Keep the ID-to-address mapping correct for each provisioning cycle. [2] [3]
Replenishment: io_uring_cqe_seen releases a completion slot, not a payload buffer back to its pool. For ordinary non-incremental buffers, finish processing a returned payload before adding and publishing that buffer again. The combined io_uring_buf_ring_cq_advance helper publishes previously added buffers while advancing the CQ; it does not populate their descriptors. [4] [5]
Continuation: in the Linux v6.16 ABI, IORING_CQE_F_MORE concerns additional completions from the request. IORING_CQE_F_BUF_MORE instead means an incrementally consumed buffer remains in use by the kernel. Do not recycle that entire buffer merely because one completion arrived; ordinary non-incremental buffer return is a different case. [6]
Relations
Advantages
- Lets supported operations select from a supplied group instead of requiring a separate preselected payload buffer for each request. [1]
Limitations
- Publishing a buffer transfers it to the ring; do not republish memory while the application or kernel still needs its contents. [3, 6]
- For multishot receive, check IORING_CQE_F_MORE on every completion, including nonnegative results; replenishing buffers does not restart a terminated request. [8]
- Multishot read requires a pollable file type; ordinary regular files fail with -EBADFD in the reviewed API. [9]
- IORING_FEAT_RECVSEND_BUNDLE in the features returned at ring setup reports the reviewed send-buffer capability; it is not an SQE flag. Supported requests still use IOSQE_BUFFER_SELECT with buf_group. [12, 13]
Citations
- liburing 2.8: buffer groups and selected IDs
- liburing 2.8: ring offsets and application buffer IDs
- liburing 2.8: publishing buffers and ownership
- liburing 2.8: completion-slot consumption
- liburing 2.8: combined CQ and buffer publication
- Linux v6.16: CQE buffer-selection and continuation flags
- liburing 2.8: receive termination and resubmission
- liburing 2.8: pollable-file requirement for multishot read
- liburing 2.8: provided buffers for supported send operations
- Linux v6.16: SEND opcode supports buffer selection
- liburing 2.8: reported send-buffer capability at ring setup
- Linux v6.10: separate setup feature bits and SQE selection flags
Further reading
Sources & caveats
- Primary documentation and pinned Linux v6.16 ABI review; no native kernel execution, performance benchmark or durability experiment.