• J
    io_uring: fix potential hang with polled IO · 500f9fba
    Jens Axboe 提交于
    If a request issue ends up being punted to async context to avoid
    blocking, we can get into a situation where the original application
    enters the poll loop for that very request before it has been issued.
    This should not be an issue, except that the polling will hold the
    io_uring uring_ctx mutex for the duration of the poll. When the async
    worker has actually issued the request, it needs to acquire this mutex
    to add the request to the poll issued list. Since the application
    polling is already holding this mutex, the workqueue sleeps on the
    mutex forever, and the application thus never gets a chance to poll for
    the very request it was interested in.
    
    Fix this by ensuring that the polling drops the uring_ctx occasionally
    if it's not making any progress.
    Reported-by: NJeffrey M. Birnbaum <jmbnyc@gmail.com>
    Signed-off-by: NJens Axboe <axboe@kernel.dk>
    500f9fba
io_uring.c 83.5 KB