aio: support kernel side submission for aio with SCQRING
authorJens Axboe <axboe@kernel.dk>
Thu, 13 Dec 2018 02:35:26 +0000 (19:35 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 3 Jan 2019 15:14:03 +0000 (08:14 -0700)
commitb006a100f85c26febd7a210b7fd339853d5e697d
tree6e8b439c013996323c5cdce611901a9ba9f38004
parent000d8b04e260941b610cc6a93e76fd2bf13e43cb
aio: support kernel side submission for aio with SCQRING

Add support for backing the io_context with either a thread, or a
workqueue and letting those handle the submission for us. This can
be used to reduce overhead for submission, or to always make submission
async. The latter is particularly useful for buffered aio, which is
now fully async with this feature.

For polled IO, we could have the kernel side thread hammer on the SQ
ring and submit when it finds IO. This would mean that an application
would NEVER have to enter the kernel to do IO! Didn't add this yet,
but it would be trivial to add.

If an application sets IOCTX_FLAG_SCQTHREAD, the io_context gets a
single thread backing. If used with buffered IO, this will limit
the device queue depth to 1, but it will be async, IOs will simply
be serialized.

Or an application can set IOCTX_FLAG_SQWQ, in which case the io_context
gets a work queue backing. The concurrency level is the mininum of
twice the available CPUs, or the queue depth specific for the context.
For this mode, we attempt to do buffered reads inline, in case they are
cached. So we should only punt to a workqueue, if we would have to block
to get our data.

Tested with polling, no polling, fixedbufs, no fixedbufs, buffered,
O_DIRECT.

See this sample application for how to use it:

http://git.kernel.dk/cgit/fio/plain/t/aio-ring.c

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