io_uring_setup_buf_ring(3)
β¨ io_uring_setup_buf_ring(3) β the liburing glow-up β¨
okay bestie, so this one lives in the liburing Manual and it's literally about setting up and registering a buffer ring for provided buffers. let's get into it π
πΈ NAME πΈ
io_uring_setup_buf_ring β setup and register buffer ring for provided buffers
π¦ SYNOPSIS π¦
#include <liburing.h>
struct io_uring_buf_ring *io_uring_setup_buf_ring(struct io_uring *ring,
unsigned int nentries,
int bgid,
unsigned int flags,
int *err);
π DESCRIPTION π
So io_uring_setup_buf_ring(3) registers a shared buffer ring that you're gonna use with provided buffers. for the request types that support it, provided buffers get handed over to the ring, and then a request can pick one out if it has IOSQE_BUFFER_SELECT set in the SQE flags β but only when the request is actually ready to receive data. the way this slays is that it gives you clear ownership of the buffer lifetime, plus a way to have more read/receive type operations in flight than you have buffers available. main character energy fr π₯
- the
ringargument must be a pointer to the ring that the provided buffer ring is being registered for nentriesis the number of entries requested in the buffer ring. this argument must be a power-of 2 in size, and can be up to 32768 in sizebgidis the chosen buffer group IDflagsare modifier flags for the operation*erris a pointer to an integer for the error value, in case any part of the ring allocation and registration fails
π flags values π
The flags argument can be set to one of the following values:
IOU_PBUF_RING_INCβ the buffers in this ring can be incrementally consumed. with partial consumption, each completion of a given buffer ID will continue where the previous one left off, or from the start if no completions have been seen yet. when more completions should be expected for a given buffer ID, the CQE will haveIORING_CQE_F_BUF_MOREset in theflagsmember. Available since 6.12.
under the covers, this function uses io_uring_register_buf_ring(3) to register the ring, and it handles the allocation of the ring itself instead of letting the application open code it. no cap, it's doing the work so you don't have to π«Ά
and to unregister and free a buffer group ID that you set up with this function, the application must call io_uring_free_buf_ring(3). don't leave it hanging bestie π
Available since 5.19.
β RETURN VALUE β
- On success,
io_uring_setup_buf_ring(3)returns a pointer to the buffer ring π - On failure it returns
NULLand sets*errto-errnoπ
π NOTES π
heads up: even if the kernel supports this feature, registering a provided buffer ring may still fail with -EINVAL if the host is a 32-bit architecture and the memory being passed in resides in high memory. it's giving β¨circumstantialβ¨, not a you problem.
π SEE ALSO π
io_uring_register_buf_ring(3)io_uring_buf_ring_init(3)io_uring_buf_ring_add(3)io_uring_buf_ring_advance(3)io_uring_buf_ring_cq_advance(3)
and that's the whole page, bestie β this one's from liburing-2.4, dated Mar 07, 2023. go register some rings and stay iconic ππ
π¦ where this page comes from
- alpine 3.23: liburing-doc 2.12-r0 Β· LGPL-2.1-or-later OR MIT
- alpine 3.24: liburing-doc 2.14-r0 Β· LGPL-2.1-or-later OR MIT
- arch rolling: liburing 2.15-1 Β· GPL-2.0-only WITH Linux-syscall-note OR MIT AND LGPL-2.0-or-later AND MIT
- centos-stream 10: liburing-devel 2.12-1.el10 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- centos-stream 9: liburing-devel 2.12-1.el9 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- centos-stream 9: liburing-devel 2.12-1.el9 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- fedora 44: liburing-devel 2.13-2.fc44 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 44: liburing-devel 2.13-2.fc44 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- nixpkgs unstable: liburing 2.14
- ubuntu resolute: liburing-dev 2.14-1
- ubuntu stonking: liburing-dev 2.15-1
- π the page's license: LGPL-2.0-or-later
- Copyright (C) 2022 Jens Axboe <axboe@kernel.dk>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms