]> git.baikalelectronics.ru Git - kernel.git/commit
io-wq: fix race between adding work and activating a free worker
authorJens Axboe <axboe@kernel.dk>
Mon, 30 Aug 2021 17:55:22 +0000 (11:55 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 31 Aug 2021 17:45:27 +0000 (11:45 -0600)
commit35c2e32fe4fa3e55b21ed19f611811e0e961efdd
tree5d8cdeace9484d67ad0270f97d5e88244a052148
parent8cd95162c2f806b97f419a8ea391b8c985e60d13
io-wq: fix race between adding work and activating a free worker

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: Andres Freund <andres@anarazel.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io-wq.c