Skip to content
Advertisement

How much locked memory does io_uring_setup need?

When using io_uring_queue_init it calls io_uring_setup. There’s an ENOMEM returned when there is insufficient amount of locked memory available for the process.

A strace will look something like:

[pid 37480] io_uring_setup(2048, {flags=0, sq_thread_cpu=0, sq_thread_idle=0}) = -1 ENOMEM (Cannot allocate memory)

What is the formula for how much locked memory is required per entry (first argument)? and if possible, based on the sq_entries/cq_entries in the params structure? Kernel code for the particularly keen. Please don’t expand the kernel page size from the formula, as I do want this to be an architecture dependent answer (if it is).

I don’t want a dodgy just set ulimit -l to unlimited as an answer. There’s this outstanding feature request feature request that would help when implemented.

Advertisement

Answer

Thanks to Jens Axboe the following to liburing library calls where added (>=liburing-2.1) returning the size in bytes, 0 if not required, or -errno for errors.

ssize_t io_uring_mlock_size(unsigned entries, unsigned flags);
ssize_t io_uring_mlock_size_params(unsigned entries, struct io_uring_params *p);
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement