aio: add support for pre-mapped user IO buffers
authorJens Axboe <axboe@kernel.dk>
Fri, 30 Nov 2018 22:21:55 +0000 (15:21 -0700)
committerJens Axboe <axboe@kernel.dk>
Tue, 4 Dec 2018 17:13:09 +0000 (10:13 -0700)
commitbb92f10a53a60a5f811c2df5cdf07b1e271280b4
tree0f68c40bdf33581f8bd25203399d39b4f2edda77
parent1c2a542c171b9b74596b9dbd2c16c9a7287e8c1e
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 set both
IOCTX_FLAG_USERIOCB, to provide iocb's in userspace, and then
IOCTX_FLAG_FIXEDBUFS. The latter tells aio that the iocbs that are
mapped 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.

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.

See the fio change for how to utilize this feature:

http://git.kernel.dk/cgit/fio/commit/?id=2041bd343da1c1e955253f62374588718c64f0f3

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