• Jens Axboe's avatar
    io_uring: avoid ring quiesce for fixed file set unregister and update · 05f3fb3c
    Jens Axboe authored
    We currently fully quiesce the ring before an unregister or update of
    the fixed fileset. This is very expensive, and we can be a bit smarter
    about this.
    
    Add a percpu refcount for the file tables as a whole. Grab a percpu ref
    when we use a registered file, and put it on completion. This is cheap
    to do. Upon removal of a file from a set, switch the ref count to atomic
    mode. When we hit zero ref on the completion side, then we know we can
    drop the previously registered files. When the old files have been
    dropped, switch the ref back to percpu mode for normal operation.
    
    Since there's a period between doing the update and the kernel being
    done with it, add a IORING_OP_FILES_UPDATE opcode that can perform the
    same action. The application knows the update has completed when it gets
    the CQE for it. Between doing the update and receiving this completion,
    the application must continue to use the unregistered fd if submitting
    IO on this particular file.
    
    This takes the runtime of test/file-register from liburing from 14s to
    about 0.7s.
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    05f3fb3c
io_uring.c 141 KB