OSDN Git Service

io_uring: improve registered buffer accounting for huge pages
authorJens Axboe <axboe@kernel.dk>
Thu, 17 Sep 2020 22:19:16 +0000 (16:19 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 1 Oct 2020 02:32:34 +0000 (20:32 -0600)
commitde2939388be564836b06f0f06b3787bdedaed822
tree78967b16e25e004b56b547a1705dd3c4571428bd
parent14db84110d489276d9c06ea38d59d3ff0ade2ae1
io_uring: improve registered buffer accounting for huge pages

io_uring does account any registered buffer as pinned/locked memory, and
checks limit and fails if the given user doesn't have a big enough limit
to register the ranges specified. However, if huge pages are used, we
are potentially under-accounting the memory in terms of what gets pinned
on the vm side.

This patch rectifies that, by ensuring that we account the full size of
a compound page, regardless of how much of it is being registered. Huge
pages are not accounted mulitple times - if multiple sections of a huge
page is registered, then the page is only accounted once.

Reported-by: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c