diff options
author | Pavel Begunkov | 2021-06-17 18:14:09 +0100 |
---|---|---|
committer | Jens Axboe | 2021-06-18 09:22:02 -0600 |
commit | 16f72070386fca59312bde696cff917bb04b183e (patch) | |
tree | 5923c7a865afa0c81c7e2243e1974606d78ee099 /fs/io_uring.c | |
parent | c6538be9e4883d1371adaff45712b1b2172773dd (diff) |
io_uring: don't resched with empty task_list
Entering tctx_task_work() with empty task_list is a strange scenario,
that can happen only on rare occasion during task exit, so let's not
check for task_list emptiness in advance and do it do-while style. The
code still correct for the empty case, just would do extra work about
which we don't care.
Do extra step and do the check before cond_resched(), so we don't
resched if have nothing to execute.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/c4173e288e69793d03c7d7ce826f9d28afba718a.1623949695.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r-- | fs/io_uring.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 51db0d80b67b..55bc348ed8fe 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1896,7 +1896,7 @@ static void tctx_task_work(struct callback_head *cb) clear_bit(0, &tctx->task_state); - while (!wq_list_empty(&tctx->task_list)) { + while (1) { struct io_wq_work_node *node; spin_lock_irq(&tctx->task_lock); @@ -1917,6 +1917,8 @@ static void tctx_task_work(struct callback_head *cb) req->task_work.func(&req->task_work); node = next; } + if (wq_list_empty(&tctx->task_list)) + break; cond_resched(); } |