diff options
author | Jens Axboe <axboe@kernel.dk> | 2023-01-27 19:50:31 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-03-10 11:34:03 +0300 |
commit | d9399e543062251cc6102e7e5d80f3bd79115316 (patch) | |
tree | 6cda2d75d247054ff41faa3e51f80a61a815193e /io_uring | |
parent | 42fe280e267a120724e139732bc7db9e13fd1914 (diff) | |
download | linux-d9399e543062251cc6102e7e5d80f3bd79115316.tar.xz |
io_uring: add reschedule point to handle_tw_list()
commit f58680085478dd292435727210122960d38e8014 upstream.
If CONFIG_PREEMPT_NONE is set and the task_work chains are long, we
could be running into issues blocking others for too long. Add a
reschedule check in handle_tw_list(), and flush the ctx if we need to
reschedule.
Cc: stable@vger.kernel.org # 5.10+
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'io_uring')
-rw-r--r-- | io_uring/io_uring.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 5dc21591bf68..78c677869308 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -1030,10 +1030,16 @@ static unsigned int handle_tw_list(struct llist_node *node, /* if not contended, grab and improve batching */ *locked = mutex_trylock(&(*ctx)->uring_lock); percpu_ref_get(&(*ctx)->refs); - } + } else if (!*locked) + *locked = mutex_trylock(&(*ctx)->uring_lock); req->io_task_work.func(req, locked); node = next; count++; + if (unlikely(need_resched())) { + ctx_flush_and_put(*ctx, locked); + *ctx = NULL; + cond_resched(); + } } return count; |