• Pavel Begunkov's avatar
    io_uring: optimise non-drain path · 441b8a78
    Pavel Begunkov authored
    Replace drain checks with one-way flag set upon seeing the first
    IOSQE_IO_DRAIN request. There are several places where it cuts cycles
    well:
    
    1) It's much faster than the fast check with two
    conditions in io_drain_req() including pretty complex
    list_empty_careful().
    
    2) We can mark io_queue_sqe() inline now, that's a huge win.
    
    3) It replaces timeout and drain checks in io_commit_cqring() with a
    single flags test. Also great not touching ->defer_list there without a
    reason so limiting cache bouncing.
    
    It adds a small amount of overhead to drain path, but it's negligible.
    The main nuisance is that once it meets any DRAIN request in io_uring
    instance lifetime it will _always_ go through a slower path, so
    drain-less and offset-mode timeout less applications are preferable.
    The overhead in that case would be not big, but it's worth to bear in
    mind.
    Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
    Link: https://lore.kernel.org/r/98d2fff8c4da5144bb0d08499f591d4768128ea3.1623709150.git.asml.silence@gmail.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
    441b8a78
io_uring.c 250 KB