aio: support kernel side submission for aio with SCQRING
authorJens Axboe <axboe@kernel.dk>
Sat, 5 Jan 2019 05:13:02 +0000 (22:13 -0700)
committerJens Axboe <axboe@kernel.dk>
Sun, 6 Jan 2019 21:55:28 +0000 (14:55 -0700)
commit858321a87604d5f3ec95cf37044a8a8e3d223d51
treef9ba35e4c7f14db5651ab5783335ff9bc3be6027
parent921d7b27a5f5f2e6c35e2dd2f05547e66ada3b44
aio: support kernel side submission for aio with SCQRING

Add support for backing the io_uring fd 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 urings get
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