Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring: pass struct io_tw_state by value

8e5b3b89ecaf ("io_uring: remove struct io_tw_state::locked") removed the
only field of io_tw_state but kept it as a task work callback argument
to "forc[e] users not to invoke them carelessly out of a wrong context".
Passing the struct io_tw_state * argument adds a few instructions to all
callers that can't inline the functions and see the argument is unused.

So pass struct io_tw_state by value instead. Since it's a 0-sized value,
it can be passed without any instructions needed to initialize it.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Link: https://lore.kernel.org/r/20250217022511.1150145-2-csander@purestorage.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Caleb Sander Mateos and committed by
Jens Axboe
94a4274b bcf8a029

+8 -8
+1 -1
include/linux/io_uring_types.h
··· 444 444 struct io_tw_state { 445 445 }; 446 446 /* Alias to use in code that doesn't instantiate struct io_tw_state */ 447 - typedef struct io_tw_state *io_tw_token_t; 447 + typedef struct io_tw_state io_tw_token_t; 448 448 449 449 enum { 450 450 REQ_F_FIXED_FILE_BIT = IOSQE_FIXED_FILE_BIT,
+7 -7
io_uring/io_uring.c
··· 255 255 percpu_ref_get(&ctx->refs); 256 256 mutex_lock(&ctx->uring_lock); 257 257 llist_for_each_entry_safe(req, tmp, node, io_task_work.node) 258 - req->io_task_work.func(req, &ts); 258 + req->io_task_work.func(req, ts); 259 259 io_submit_flush_completions(ctx); 260 260 mutex_unlock(&ctx->uring_lock); 261 261 percpu_ref_put(&ctx->refs); ··· 1052 1052 io_task_work.node); 1053 1053 1054 1054 if (req->ctx != ctx) { 1055 - ctx_flush_and_put(ctx, &ts); 1055 + ctx_flush_and_put(ctx, ts); 1056 1056 ctx = req->ctx; 1057 1057 mutex_lock(&ctx->uring_lock); 1058 1058 percpu_ref_get(&ctx->refs); 1059 1059 } 1060 1060 INDIRECT_CALL_2(req->io_task_work.func, 1061 1061 io_poll_task_func, io_req_rw_complete, 1062 - req, &ts); 1062 + req, ts); 1063 1063 node = next; 1064 1064 (*count)++; 1065 1065 if (unlikely(need_resched())) { 1066 - ctx_flush_and_put(ctx, &ts); 1066 + ctx_flush_and_put(ctx, ts); 1067 1067 ctx = NULL; 1068 1068 cond_resched(); 1069 1069 } 1070 1070 } while (node && *count < max_entries); 1071 1071 1072 - ctx_flush_and_put(ctx, &ts); 1072 + ctx_flush_and_put(ctx, ts); 1073 1073 return node; 1074 1074 } 1075 1075 ··· 1341 1341 1342 1342 if (!io_local_work_pending(ctx)) 1343 1343 return 0; 1344 - return __io_run_local_work(ctx, &ts, min_events, 1344 + return __io_run_local_work(ctx, ts, min_events, 1345 1345 max(IO_LOCAL_TW_DEFAULT_MAX, min_events)); 1346 1346 } 1347 1347 ··· 1352 1352 int ret; 1353 1353 1354 1354 mutex_lock(&ctx->uring_lock); 1355 - ret = __io_run_local_work(ctx, &ts, min_events, max_events); 1355 + ret = __io_run_local_work(ctx, ts, min_events, max_events); 1356 1356 mutex_unlock(&ctx->uring_lock); 1357 1357 return ret; 1358 1358 }