io_uring_register_ring_fd(3)
π io_uring_register_ring_fd β register a ring file descriptor π
okay bestie, gather round, because this one is a little function with big main character energy β¨ it lives in liburing, and it's basically "hey kernel, remember my ring fd so you stop doing extra paperwork every single time" π
β¨ SYNOPSIS β¨
#include <liburing.h>
int io_uring_register_ring_fd(struct io_uring *ring);
πΈ DESCRIPTION πΈ
So io_uring_register_ring_fd(3) registers the file descriptor of the ring. That's it. That's the whole vibe. π
Here's the tea though: every time io_uring_enter(2) gets called β whether you're submitting a request or waiting on completions β the kernel has to grab a reference to the file descriptor. And if the app using io_uring is threaded, the file table gets marked as shared, and suddenly that reference grab-and-put on the file descriptor count costs way more than it does for a non-threaded app. it's giving unnecessary overhead, fr fr π
So, kind of like how io_uring already lets you register files, this lil function lets you register the ring file descriptor itself. Which means the overhead of the io_uring_enter(2) system call goes down. slay. π₯
And like β if your app using liburing is threaded, you should call this function to register the ring descriptor when the ring gets set up. Just do it, bestie π«Ά
heads up tho: check out NOTES for the restrictions that apply when a ring is shared π
Available since kernel 5.18. β
π¦ NOTES π¦
When the ring descriptor is registered, it gets stored internally in the struct io_uring structure. periodt.
But here's where it gets spicy πΆοΈ β for applications that share a ring between threads, like one thread doing the submits and another reaping events, this optimization cannot be used, because each thread may have a different index for the registered ring fd. so yeah, that one's off the table. sorry bestie ππ
π RETURN VALUE π
Returns 1 on success β indicating that one file descriptor was registered β or -errno on error. that's the whole return journey, no cap π
π SEE ALSO π
and that's the page, bestie!! π this lil baddie comes to you courtesy of liburing-2.2, dated March 11, 2022 β go forth and register that ring fd, you absolute icon πβ¨π¦π
π¦ 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
- 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
- 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
- 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