-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
liburing feature: return memory that'd be locked for a certain ring size #246
Comments
This should just go in liburing imho. I'm taking name suggestions :-) |
How about: size_t io_uring_memlock_required(unsigned entries, unsigned flags);
size_t io_uring_memlock_required_params(unsigned entries, struct io_uring_params *p); not super happy about the If you wanted to make it a bit more general, it could be something like struct io_uring_sizes {
size_t kernel_memlock;
...
};
void io_uring_get_sizes(struct io_uring_sizes *s, unsigned entries, unsigned flags);
void io_uring_get_sizes_params(struct io_uring_sizes *s, unsigned entries, struct io_uring_params *p); or such, but I'm a bit doubtful it's warranted. |
I guess the trickier bit here is ensuring this works regardless of page size in the system, as that may impact it. I guess that's a vote for actually putting this in the kernel, outside of just having the one implementation of it... |
To add another vote, yes please. At the moment MariaDB has a really crap error message that only partially hints at a solution - https://github.com/MariaDB/server/blob/10.6/tpool/aio_liburing.cc#L41-L43. |
I'd suggest small tweak (to the simple version): size_t io_uring_mlock_size(unsigned entries, unsigned flags);
size_t io_uring_mlock_size_params(unsigned entries, struct io_uring_params *p); |
Question is how this should behave for 5.12 and newer, where we don't memlock anything? I guess we can just return 0 for that case. |
Seems very reasonable, yes. |
Works for me. |
Can either (or both!) of you try that mlock-size branch? It provides the two requested helpers. I can some quick sanity checking here and it looks sane. https://git.kernel.dk/cgit/liburing/commit/?h=mlock-size&id=ea0fd51b78b3c089add37e8c4ee61abd460beb7a |
ok. I'll take a spin/test in the next few days. Thank you. |
Can I just clarify the units returned?
so 2112 is the raw value returned. I'm getting ENOMEM on ulimit -l 128 but succeeding on ulimit -l 256. No locked memory is currently used. $ grep locked /proc/872691/limits Max locked memory 131072 131072 bytes $ grep VmLck /proc/872691/status VmLck: 0 kB |
Hmm, that seems odd. A quick test here with (2048, 0) returns 262144, which seems more in line with what you need. The returned value is in bytes. Where's your 2112 coming from? Running with (1, 0) here returns 8192, 8k, or 4 pages. |
Ok found it, a 2112 was my error. However running on an older kernel (5.11.10) without sufficient locked memory available causes This seems to be for the population of
I've tested this an it generates the correct result for me:
|
Yes, that's a good idea, I'll add that. |
Done, and merged to master. |
This gives the user the size required and how to set memlock limits for the process. Thanks Jens Axboe for providing this requested interface ref: axboe/liburing#246 Also don't put \n on my_printf_error, its implicit.
Hi,
For applications that do not run as root, and that are often run outside of very controlled environments, there is a tension between the number and size of rings used by default, and the likelihood of running into RLIMIT_MEMLOCK.
It'd be useful if liburing had a function that calculated how much memory a ring of a certain size would take. That'd make it easier for applications to tune themselves appropriately.
I can see two possible ways to implement this:
Regards,
Andres
The text was updated successfully, but these errors were encountered: