diff options
| author | Ali Ahmet Memis <ali@iusegentoo.com> | 2026-08-06 18:00:44 +0000 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2026-08-15 17:55:48 -0600 |
| commit | f12f0234cc14886bcfd53ffb7c8df4216dad51f1 (patch) | |
| tree | 1e21b7f1ab6d34b65f11df152e2f0ea81b6675ba /scripts/Makefile.thinlto | |
| parent | 3c8a5e271594f6ba6d2af40f229cbcd0bcb08c06 (diff) | |
| download | linux-stable-f12f0234cc14886bcfd53ffb7c8df4216dad51f1.tar.gz linux-stable-f12f0234cc14886bcfd53ffb7c8df4216dad51f1.zip | |
io_uring/memmap: account the pages a compound region really uses
io_mem_alloc_compound() allocates get_order(size) pages, which rounds a
region size that is not a power of two up to the next order. The pages
past the region are part of the same allocation and cannot be used for
anything else, but io_create_region() accounts reg->size >> PAGE_SHIFT,
so they are never charged against RLIMIT_MEMLOCK. For a ring with 4096
SQ entries and the default CQ size the region is 37 pages while the
allocation is 64.
Account the tail pages together with the region, and fall back to the
exact sized bulk allocation when they do not fit the limit, so a user
close to their limit still gets the region rather than an error.
io_free_region() gives the same amount back, the compound case being the
one that set IO_REGION_F_SINGLE_REF.
Counting how many 4096 entry rings an unprivileged user can create under
a given RLIMIT_MEMLOCK, before and after:
limit (pages) before after
256 2 2
300 2 2
350 3 2
400 3 3
512 5 4
Five rings under a 512 page limit really pin 640 pages.
Fixes: dfbbfbf19187 ("io_uring: introduce concept of memory regions")
Link: https://lore.kernel.org/all/87ik5ncj8d.fsf@mailhost.krisman.be/
Signed-off-by: Ali Ahmet Memis <ali@iusegentoo.com>
Link: https://patch.msgid.link/20260806180044.275543-1-ali@iusegentoo.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions
