io_uring_mlock_size(3)
π io_uring_mlock_size β get required memlock size for a ring π
okay bestie, so you know how io_uring is this whole liburing thing and you're like "how much memlock do I even need for my ring??" β this page is literally that. it's from the liburing manual, section 3 (that's the library-functions section, iykyk), and it's here to tell you the exact number so you don't have to guess. π
β¨ SYNOPSIS β¨
#include <liburing.h>
ssize_t io_uring_mlock_size(unsigned entries, unsigned flags);
πΈ DESCRIPTION πΈ
so io_uring_mlock_size(3) is the function that returns the required RLIMIT_MEMLOCK memory size for an io_uring ring that has entries entries and whatever setup flags you passed in. that's it, that's the whole job. π
now here's the tea, and it depends on your kernel:
- on newer kernels (5.12+),
io_uringno longer requires any memlock memory, and this function will return0. yes, zero, nothing, she's free π¦ - on older kernels (5.11 and prior), this returns the required memory so that the caller can make sure there's enough
RLIMIT_MEMLOCKspace available before setting up a ring. like checking your bank balance before you tap your card, fr fr.
and if you want more control over the ring parameters? use io_uring_mlock_size_params(3) instead. that one's the glow-up version. β¨
π«Ά RETURN VALUE π«Ά
- returns the required memlock size in bytes on success π
- returns
0if no memlock is needed (hi, modern kernels) π - or a negative errno value on error π
π SEE ALSO π
io_uring_mlock_size_params(3)io_uring_memory_size(3)io_uring_queue_init(3)getrlimit(2)
lowkey important reminder: don't just vibe-check this number into existence β the whole point is calling it before you set up the ring, so future-you doesn't get yelled at by the kernel. π
and that's a wrap, bestie π this was liburing-2.4, dated January 18, 2025 β mwah, go touch some ring buffers πβ¨
π¦ where this page comes from
- 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
- 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) 2025 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