diff options
author | Jens Axboe <axboe@kernel.dk> | 2021-02-16 14:15:30 -0700 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-02-21 17:25:22 -0700 |
commit | 3bfe6106693b6b4ba175ad1f929c4660b8f59ca8 (patch) | |
tree | aba6783414bf41a0274cc07c5cf4d11912de3ba6 /fs/io_uring.c | |
parent | 6fb8f43cede0e4bd3ead847de78d531424a96be9 (diff) | |
download | lwn-3bfe6106693b6b4ba175ad1f929c4660b8f59ca8.tar.gz lwn-3bfe6106693b6b4ba175ad1f929c4660b8f59ca8.zip |
io-wq: fork worker threads from original task
Instead of using regular kthread kernel threads, create kernel threads
that are like a real thread that the task would create. This ensures that
we get all the context that we need, without having to carry that state
around. This greatly reduces the code complexity, and the risk of missing
state for a given request type.
With the move away from kthread, we can also dump everything related to
assigned state to the new threads.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r-- | fs/io_uring.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 31402a19fca6..9d22ec9d9406 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1633,6 +1633,9 @@ static struct io_kiocb *__io_queue_async_work(struct io_kiocb *req) struct io_kiocb *link = io_prep_linked_timeout(req); struct io_uring_task *tctx = req->task->io_uring; + BUG_ON(!tctx); + BUG_ON(!tctx->io_wq); + trace_io_uring_queue_async_work(ctx, io_wq_is_hashed(&req->work), req, &req->work, req->flags); io_wq_enqueue(tctx->io_wq, &req->work); @@ -9240,6 +9243,10 @@ static int io_uring_flush(struct file *file, void *data) struct io_uring_task *tctx = current->io_uring; struct io_ring_ctx *ctx = file->private_data; + /* Ignore helper thread files exit */ + if (current->flags & PF_IO_WORKER) + return 0; + if (fatal_signal_pending(current) || (current->flags & PF_EXITING)) { io_uring_cancel_task_requests(ctx, NULL); io_req_caches_free(ctx, current); |