io-wq: eliminate the need for a manager thread
authorJens Axboe <axboe@kernel.dk>
Mon, 8 Mar 2021 16:37:51 +0000 (09:37 -0700)
committerJens Axboe <axboe@kernel.dk>
Sun, 4 Apr 2021 21:27:39 +0000 (15:27 -0600)
commit6c40d316ff3a9e583a43f014c2e6d054e2f4bb7d
tree5a8b89da9ab55a95b8c9f5a6d8ec1cfc2c6f0701
parent5c392b3de634a7a26f23ab52275b9354395999e8
io-wq: eliminate the need for a manager thread

io-wq relies on a manager thread to create/fork new workers, as needed.
But there's really no strong need for it anymore. We have the following
cases that fork a new worker:

1) Work queue. This is done from the task itself always, and it's trivial
   to create a worker off that path, if needed.

2) All workers have gone to sleep, and we have more work. This is called
   off the sched out path. For this case, use a task_work items to queue
   a fork-worker operation.

3) Hashed work completion. Don't think we need to do anything off this
   case. If need be, it could just use approach 2 as well.

Part of this change is incrementing the running worker count before the
fork, to avoid cases where we observe we need a worker and then queue
creation of one. Then new work comes in, we fork a new one. That last
queue operation should have waited for the previous worker to come up,
it's quite possible we don't even need it. Hence move the worker running
from before we fork it off to more efficiently handle that case.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io-wq.c
fs/io-wq.h
fs/io_uring.c