author: Jens Axboe <axboe@kernel.dk> 2023-01-27 09:50:31 -0700
committer: Jens Axboe <axboe@kernel.dk> 2023-01-29 15:17:41 -0700
commit: f58680085478dd292435727210122960d38e8014
parent: fcc926bb857949dbfa51a7d95f3f5ebc657f198c
Commit Summary:
Diffstat:
1 file changed, 7 insertions, 1 deletion
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index fab581a31dc1..acf6d9680d76 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -1179,10 +1179,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;