io_uring: make task_work pending check dependent on ring type
authorJens Axboe <axboe@kernel.dk>
Thu, 21 Nov 2024 15:27:10 +0000 (08:27 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 16 Jun 2025 21:41:46 +0000 (15:41 -0600)
There's no need to check for generic task_work for DEFER_TASKRUN, if we
have local task_work pending. This avoids dipping into the huge
task_struct, if we have normal task_work pending.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.h

index d59c12277d58ce35d072529697faec7dc7e7dd76..56becba55c7e18700df4fb0a5ed112c45f5b0287 100644 (file)
@@ -388,7 +388,9 @@ static inline bool io_local_work_pending(struct io_ring_ctx *ctx)
 
 static inline bool io_task_work_pending(struct io_ring_ctx *ctx)
 {
-       return task_work_pending(current) || io_local_work_pending(ctx);
+       if (ctx->flags & IORING_SETUP_DEFER_TASKRUN && io_local_work_pending(ctx))
+               return true;
+       return task_work_pending(current);
 }
 
 static inline void io_tw_lock(struct io_ring_ctx *ctx, io_tw_token_t tw)