io_uring: add support for NO_OFFLOAD
authorJens Axboe <axboe@kernel.dk>
Wed, 19 Apr 2023 14:19:47 +0000 (08:19 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 27 Apr 2023 01:15:28 +0000 (19:15 -0600)
commit20ba534c74dd7321965093b3eb917dde246032b5
treea0d493cd11583363af93d24b628efd2d00e5f00f
parentbf4517f4f3bdcdac3dc5b35e8831784545d7176f
io_uring: add support for NO_OFFLOAD

Some applications don't necessarily care about io_uring not blocking for
request issue, they simply want to use io_uring for batched submission
of IO. However, io_uring will always do non-blocking issues, and for
some request types, there's simply no support for doing non-blocking
issue and hence they get punted to io-wq unconditionally. If the
application doesn't care about issue potentially blocking, this causes
a performance slowdown as thread offload is not nearly as efficient as
inline issue.

Add support for configuring the ring with IORING_SETUP_NO_OFFLOAD, and
add an IORING_ENTER_NO_OFFLOAD flag to io_uring_enter(2). If either one
of these is set, then io_uring will ignore the non-block issue attempt
for any file which we cannot poll for readiness. The simplified io_uring
issue model looks as follows:

1) Non-blocking issue is attempted for IO. If successful, we're done for
   now.

2) Case 1 failed. Now we have two options
   a) We can poll the file. We arm poll, and we're done for now
   until that triggers.
    b) File cannot be polled, we punt to io-wq which then does a
   blocking attempt.

If either of the NO_OFFLOAD flags are set, we should never hit case
2b. Instead, case 1 would issue the IO without the non-blocking flag
being set and perform an inline completion.

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