io_uring: add IORING_REGISTER_COPY_BUFFERS method for-6.12/io_uring-20240913
authorJens Axboe <axboe@kernel.dk>
Wed, 11 Sep 2024 19:56:08 +0000 (13:56 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 12 Sep 2024 16:14:15 +0000 (10:14 -0600)
commit7cc2a6eadcd7a5aa36ac63e6659f5c6138c7f4d2
tree12a31834fe775550d66934215aa5f8f8140dc906
parent0b6d253e084a97a05f4970dee06d9a75d29a7bda
io_uring: add IORING_REGISTER_COPY_BUFFERS method

Buffers can get registered with io_uring, which allows to skip the
repeated pin_pages, unpin/unref pages for each O_DIRECT operation. This
reduces the overhead of O_DIRECT IO.

However, registrering buffers can take some time. Normally this isn't an
issue as it's done at initialization time (and hence less critical), but
for cases where rings can be created and destroyed as part of an IO
thread pool, registering the same buffers for multiple rings become a
more time sensitive proposition. As an example, let's say an application
has an IO memory pool of 500G. Initial registration takes:

Got 500 huge pages (each 1024MB)
Registered 500 pages in 409 msec

or about 0.4 seconds. If we go higher to 900 1GB huge pages being
registered:

Registered 900 pages in 738 msec

which is, as expected, a fully linear scaling.

Rather than have each ring pin/map/register the same buffer pool,
provide an io_uring_register(2) opcode to simply duplicate the buffers
that are registered with another ring. Adding the same 900GB of
registered buffers to the target ring can then be accomplished in:

Copied 900 pages in 17 usec

While timing differs a bit, this provides around a 25,000-40,000x
speedup for this use case.

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