io_uring_buf_ring_add(3)
π io_uring_buf_ring_add(3) π
okay bestie, so this one lives in the liburing Manual and it's literally the glow-up your buffer ring has been waiting for β¨
πΈ NAME πΈ
io_uring_buf_ring_add β add buffers to a shared buffer ring π
π¦ SYNOPSIS π¦
#include <liburing.h>
void io_uring_buf_ring_add(struct io_uring_buf_ring *br,
void *addr,
unsigned int len,
unsigned short bid,
int mask,
int buf_offset);
β¨ DESCRIPTION β¨
so io_uring_buf_ring_add(3) does the thing where it slides a brand new buffer into the shared buffer ring br. it's giving adding to the roster, no cap π
the buffer's address is addr, and it's len bytes long. simple as that.
bidβ this is the buffer ID, and bestie, it's coming back to you in the CQE. remember it. own it. πmaskβ the size mask of the ring, which you get fromio_uring_buf_ring_mask(3).buf_offsetβ the offset to insert at from the current tail.
now here's the part where people get it wrong, so listen up π«Ά if you're adding just one buffer before committing the ring tail with io_uring_buf_ring_advance(3) or io_uring_buf_ring_cq_advance(3), then buf_offset should be 0. periodt. but if you're adding buffers in a loop before committing them, then buf_offset must be incremented by one for every single buffer you add. not two. not zero. one. increment it. don't skip. π
π RETURN VALUE π
None. it literally returns nothing. it's a void. that's it, that's the whole section π
π₯ NOTES π₯
ngl this is the part that makes everything click: liburing (and the kernel, for that matter) does not care about what buffer ID maps to what buffer. like, zero opinions. none. π
and when you're recycling buffers after use? the application is totally free to add a different buffer into the same buffer ID location. iconic behavior, honestly. all that matters is that the application knows what a given buffer ID corresponds to in time in terms of virtual memory. that's the whole vibe check.
there's no liburing or kernel assumption that these mappings are persistent over time. they can very well be different every single time a given buffer ID is added to the provided buffer ring. so don't get attached. it's not that kind of relationship πβ¨
π SEE ALSO π
io_uring_register_buf_ring(3)io_uring_buf_ring_mask(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.2, dated May 18, 2022 β go forth and add those buffers, increment that buf_offset, and slay π
πβ¨π¦
π¦ where this page comes from
- alpine 3.22: liburing-doc 2.9-r0 Β· LGPL-2.1-or-later OR MIT
- 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
- 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
- debian trixie: liburing-dev 2.9-1
- fedora 43: liburing-devel 2.9-2.fc43 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 43: liburing-devel 2.9-2.fc43 Β· (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)
- 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
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- ubuntu questing: liburing-dev 2.11-1
- ubuntu resolute: liburing-dev 2.14-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