io_uring_memory_size_params(3)

✨ io_uring_memory_size_params β€” the "how much RAM do I need tho" oracle ✨

okay bestie, we're in the liburing manual, section 3, and today's main character is io_uring_memory_size_params. πŸŽ€


πŸ’– NAME πŸ’–

io_uring_memory_size_params β€” get the memory size needed for a ring, but with params this time 🫢


🌸 SYNOPSIS 🌸

#include <liburing.h>

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

πŸ¦‹ DESCRIPTION πŸ¦‹

so like. the io_uring_memory_size_params(3) function tells you the total memory size needed for an io_uring ring β€” specifically a ring with entries entries plus whatever parameters you've shoved into p. no cap, that's the whole vibe. ✨

it's giving pre-allocation realness, because this is for the girlies whose applications either

  • want to pre-allocate memory for a ring ahead of time, or
  • just want to know the memory footprint before actually creating a ring πŸ‘€

now here's the tea: this function is lowkey more powerful than io_uring_memory_size(3), because it hands the caller full ring parameters. that means you can specify the CQ size via p->cq_entries β€” but only when IORING_SETUP_CQSIZE is set in p->flags. it's giving "control freak but make it a syscall" πŸ’…


πŸ’œ RETURN VALUE πŸ’œ

  • on success β€” returns the required memory size in bytes πŸŽ‰
  • on error β€” returns a negative errno value 😭

and the one error we know about:

  • -EINVAL β€” the entries value is invalid. that means it's either 0, or it's too large and you didn't pass IORING_SETUP_CLAMP. bestie, clamp it or fix it. πŸ™ˆ

πŸ‘‘ SEE ALSO πŸ‘‘


okay that's the whole page, you ate that. this was brought to you by liburing-2.11, dated January 18, 2025 β€” periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from