• Jens Axboe's avatar
    io_uring: add IORING_REGISTER_COPY_BUFFERS method · 7cc2a6ea
    Jens Axboe authored
    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: default avatarJens Axboe <axboe@kernel.dk>
    7cc2a6ea
register.c 13.9 KB