• J
    io-wq: fix race between adding work and activating a free worker · 94ffb0a2
    Jens Axboe 提交于
    The attempt to find and activate a free worker for new work is currently
    combined with creating a new one if we don't find one, but that opens
    io-wq up to a race where the worker that is found and activated can
    put itself to sleep without knowing that it has been selected to perform
    this new work.
    
    Fix this by moving the activation into where we add the new work item,
    then we can retain it within the wqe->lock scope and elimiate the race
    with the worker itself checking inside the lock, but sleeping outside of
    it.
    
    Cc: stable@vger.kernel.org
    Reported-by: NAndres Freund <andres@anarazel.de>
    Signed-off-by: NJens Axboe <axboe@kernel.dk>
    94ffb0a2
io-wq.c 28.7 KB