• Jens Axboe's avatar
    io_uring/napi: fix timeout calculation · 415ce0ea
    Jens Axboe authored
    Not quite sure what __io_napi_adjust_timeout() was attemping to do, it's
    adjusting both the NAPI timeout and the general overall timeout, and
    calculating a value that is never used. The overall timeout is a super
    set of the NAPI timeout, and doesn't need adjusting. The only thing we
    really need to care about is that the NAPI timeout doesn't exceed the
    overall timeout. If a user asked for a timeout of eg 5 usec and NAPI
    timeout is 10 usec, then we should not spin for 10 usec.
    
    While in there, sanitize the time checking a bit. If we have a negative
    value in the passed in timeout, discard it. Round up the value as well,
    so we don't end up with a NAPI timeout for the majority of the wait,
    with only a tiny sleep value at the end.
    
    Hence the only case we need to care about is if the NAPI timeout is
    larger than the overall timeout. If it is, cap the NAPI timeout at what
    the overall timeout is.
    
    Cc: stable@vger.kernel.org
    Fixes: 8d0c12a8 ("io-uring: add napi busy poll support")
    Reported-by: default avatarLewis Baker <lewissbaker@gmail.com>
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    415ce0ea
napi.c 7.77 KB