aio: add support for pre-mapped user IO buffers
authorJens Axboe <axboe@kernel.dk>
Fri, 4 Jan 2019 19:52:45 +0000 (12:52 -0700)
committerJens Axboe <axboe@kernel.dk>
Sun, 6 Jan 2019 20:52:49 +0000 (13:52 -0700)
commit921d7b27a5f5f2e6c35e2dd2f05547e66ada3b44
tree4587fa0859097948b04786bd7ea52c23a750b54b
parent817c739877e4af79ffe4d28135dc0581026a42d6
aio: add support for pre-mapped user IO buffers

If we have fixed user buffers, we can map them into the kernel when we
setup the io_context. That avoids the need to do get_user_pages() for
each and every IO.

To utilize this feature, the application must use the SCQRING interface,
and additionally set IOCTX_FLAG_FIXEDBUFS when creating the IO context
and pass in an array of iovecs that contain the desired buffer addresses
and lengths. These buffers can then be mapped into the kernel for the
life time of the io_context, as opposed to just the duration of the each
single IO.

It's perfectly valid to setup a larger buffer, and then sometimes only
use parts of it for an IO. As long as the range is within the originally
mapped region, it will work just fine.

Only works with non-vectored read/write commands for now, not with
PREADV/PWRITEV.

A limit of 4M is imposed as the largest buffer we currently support.
There's nothing preventing us from going larger, but we need some cap,
and 4M seemed like it would definitely be big enough. RLIMIT_MEMLOCK
is used to cap the total amount of memory pinned.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/aio.c
include/uapi/linux/aio_abi.h