• Jens Axboe's avatar
    io-wq: ensure we have a stable view of ->cur_work for cancellations · 36c2f922
    Jens Axboe authored
    worker->cur_work is currently protected by the lock of the wqe that the
    worker belongs to. When we send a signal to a worker, we need a stable
    view of ->cur_work, so we need to hold that lock. But this doesn't work
    so well, since we have the opposite order potentially on queueing work.
    If POLL_ADD is used with a signalfd, then io_poll_wake() is called with
    the signal lock, and that sometimes needs to insert work items.
    
    Add a specific worker lock that protects the current work item. Then we
    can guarantee that the task we're sending a signal is currently
    processing the exact work we think it is.
    Reported-by: default avatarPaul E. McKenney <paulmck@kernel.org>
    Reviewed-by: default avatarPaul E. McKenney <paulmck@kernel.org>
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    36c2f922
io-wq.c 25.8 KB