io_uring_mlock_size_params(3)

πŸ’– io_uring_mlock_size_params β€” bestie edition πŸ’–

okay so this is io_uring_mlock_size_params from the liburing manual, and it's literally the glow-up version of a memlock-size checker. it's giving "tell me exactly how much memory i need before i do the thing." ✨


🌸 NAME 🌸

io_uring_mlock_size_params β€” get the required memlock size for a ring that has params, no cap 🫢


✨ SYNOPSIS ✨

#include <liburing.h>

ssize_t io_uring_mlock_size_params(unsigned entries, struct io_uring_params *p);

πŸ’… DESCRIPTION πŸ’…

so like. the io_uring_mlock_size_params(3) function hands you back the required RLIMIT_MEMLOCK memory size for an io_uring ring that has entries entries and the parameters you put in p. that's it, that's the whole vibe check. πŸ’–

here's the plot twist tho: on the newer kernels (5.12+), io_uring doesn't need any memlock memory at all anymore, so this function will just return 0. iconic. but on the older kernels (5.11 and prior), it returns the required memory so you can make sure there's enough RLIMIT_MEMLOCK space available before you even set up a ring. lowkey essential for the old-kernel girlies. 😭

and the way this one is better than io_uring_mlock_size(3)? it gives you way more control, because you get to specify the full ring parameters, including the CQ size via p->cq_entries β€” but only when IORING_SETUP_CQSIZE is set in p->flags. periodt. πŸ‘‘


🌈 RETURN VALUE 🌈

  • on success β†’ the required memlock size in bytes πŸ’–
  • if no memlock is needed β†’ 0 (slay)
  • on error β†’ a negative errno value πŸ™ˆ

πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page bestie, mwah πŸ’‹ this one's from liburing-2.4, dated January 18, 2025, and yes the page is literally named io_uring_mlock_size_params(3) β€” go check your memlock, ily, bye πŸŽ€βœ¨πŸ«Ά

πŸ“¦ where this page comes from