]> Gentwo Git Trees - linux/.git/commitdiff
io_uring: only call io_should_terminate_tw() once for ctx
authorCaleb Sander Mateos <csander@purestorage.com>
Fri, 31 Oct 2025 20:34:28 +0000 (14:34 -0600)
committerJens Axboe <axboe@kernel.dk>
Mon, 3 Nov 2025 15:31:26 +0000 (08:31 -0700)
io_fallback_req_func() calls io_should_terminate_tw() on each req's ctx.
But since the reqs all come from the ctx's fallback_llist, req->ctx will
be ctx for all of the reqs. Therefore, compute ts.cancel as
io_should_terminate_tw(ctx) just once, outside the loop.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c

index 93a1cc2bf3830479ad8cd8f0f5b936277311cc36..4e6676ac4662599df24607905e35cd35d6edf199 100644 (file)
@@ -289,10 +289,9 @@ static __cold void io_fallback_req_func(struct work_struct *work)
 
        percpu_ref_get(&ctx->refs);
        mutex_lock(&ctx->uring_lock);
-       llist_for_each_entry_safe(req, tmp, node, io_task_work.node) {
-               ts.cancel = io_should_terminate_tw(req->ctx);
+       ts.cancel = io_should_terminate_tw(ctx);
+       llist_for_each_entry_safe(req, tmp, node, io_task_work.node)
                req->io_task_work.func(req, ts);
-       }
        io_submit_flush_completions(ctx);
        mutex_unlock(&ctx->uring_lock);
        percpu_ref_put(&ctx->refs);