aio: add support for pre-mapped user IO buffers
authorJens Axboe <axboe@kernel.dk>
Thu, 13 Dec 2018 02:32:38 +0000 (19:32 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 3 Jan 2019 15:14:03 +0000 (08:14 -0700)
commit000d8b04e260941b610cc6a93e76fd2bf13e43cb
tree896f22d4185520dc040de618c18794bce02008b7
parentce660f2d788d279e1bfbeac2dd511486c029643c
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.
The latter tells aio that the iocbs in the SQ ring already contain valid
destination and sizes. 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