diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 0580ca510427..d7f87157be9a 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -2217,9 +2217,12 @@ static void tctx_task_work(struct callback_head *cb) } req->io_task_work.func(req, &locked); node = next; + if (unlikely(need_resched())) { + ctx_flush_and_put(ctx, &locked); + ctx = NULL; + cond_resched(); + } } while (node); - - cond_resched(); } ctx_flush_and_put(ctx, &locked);