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: avoid normal tw intermediate fallback

When a DEFER_TASKRUN io_uring is terminating it requeues deferred task
work items as normal tw, which can further fallback to kthread
execution. Avoid this extra step and always push them to the fallback
kthread.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/d1cd472cec2230c66bd1c8d412a5833f0af75384.1730772720.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
af0a2ffe 6bf90bd8

+11 -12
+10 -11
io_uring/io_uring.c
··· 1066 1066 return node; 1067 1067 } 1068 1068 1069 - static __cold void io_fallback_tw(struct io_uring_task *tctx, bool sync) 1069 + static __cold void __io_fallback_tw(struct llist_node *node, bool sync) 1070 1070 { 1071 - struct llist_node *node = llist_del_all(&tctx->task_list); 1072 1071 struct io_ring_ctx *last_ctx = NULL; 1073 1072 struct io_kiocb *req; 1074 1073 ··· 1091 1092 flush_delayed_work(&last_ctx->fallback_work); 1092 1093 percpu_ref_put(&last_ctx->refs); 1093 1094 } 1095 + } 1096 + 1097 + static void io_fallback_tw(struct io_uring_task *tctx, bool sync) 1098 + { 1099 + struct llist_node *node = llist_del_all(&tctx->task_list); 1100 + 1101 + __io_fallback_tw(node, sync); 1094 1102 } 1095 1103 1096 1104 struct llist_node *tctx_task_work_run(struct io_uring_task *tctx, ··· 1253 1247 1254 1248 static void __cold io_move_task_work_from_local(struct io_ring_ctx *ctx) 1255 1249 { 1256 - struct llist_node *node; 1250 + struct llist_node *node = llist_del_all(&ctx->work_llist); 1257 1251 1258 - node = llist_del_all(&ctx->work_llist); 1259 - while (node) { 1260 - struct io_kiocb *req = container_of(node, struct io_kiocb, 1261 - io_task_work.node); 1262 - 1263 - node = node->next; 1264 - io_req_normal_work_add(req); 1265 - } 1252 + __io_fallback_tw(node, false); 1266 1253 } 1267 1254 1268 1255 static bool io_run_local_work_continue(struct io_ring_ctx *ctx, int events,
+1 -1
io_uring/io_uring.h
··· 136 136 * Not from an SQE, as those cannot be submitted, but via 137 137 * updating tagged resources. 138 138 */ 139 - if (ctx->submitter_task->flags & PF_EXITING) 139 + if (percpu_ref_is_dying(&ctx->refs)) 140 140 lockdep_assert(current_work()); 141 141 else 142 142 lockdep_assert(current == ctx->submitter_task);