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: cleanup handle_tw_list() calling convention

Now that we don't loop around task_work anymore, there's no point in
maintaining the ring and locked state outside of handle_tw_list(). Get
rid of passing in those pointers (and pointers to pointers) and just do
the management internally in handle_tw_list().

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

+13 -16
+13 -16
io_uring/io_uring.c
··· 1173 1173 percpu_ref_put(&ctx->refs); 1174 1174 } 1175 1175 1176 - static unsigned int handle_tw_list(struct llist_node *node, 1177 - struct io_ring_ctx **ctx, 1178 - struct io_tw_state *ts) 1176 + static unsigned int handle_tw_list(struct llist_node *node) 1179 1177 { 1178 + struct io_ring_ctx *ctx = NULL; 1179 + struct io_tw_state ts = { }; 1180 1180 unsigned int count = 0; 1181 1181 1182 1182 do { ··· 1184 1184 struct io_kiocb *req = container_of(node, struct io_kiocb, 1185 1185 io_task_work.node); 1186 1186 1187 - if (req->ctx != *ctx) { 1188 - ctx_flush_and_put(*ctx, ts); 1189 - *ctx = req->ctx; 1187 + if (req->ctx != ctx) { 1188 + ctx_flush_and_put(ctx, &ts); 1189 + ctx = req->ctx; 1190 1190 /* if not contended, grab and improve batching */ 1191 - ts->locked = mutex_trylock(&(*ctx)->uring_lock); 1192 - percpu_ref_get(&(*ctx)->refs); 1191 + ts.locked = mutex_trylock(&ctx->uring_lock); 1192 + percpu_ref_get(&ctx->refs); 1193 1193 } 1194 1194 INDIRECT_CALL_2(req->io_task_work.func, 1195 1195 io_poll_task_func, io_req_rw_complete, 1196 - req, ts); 1196 + req, &ts); 1197 1197 node = next; 1198 1198 count++; 1199 1199 if (unlikely(need_resched())) { 1200 - ctx_flush_and_put(*ctx, ts); 1201 - *ctx = NULL; 1200 + ctx_flush_and_put(ctx, &ts); 1201 + ctx = NULL; 1202 1202 cond_resched(); 1203 1203 } 1204 1204 } while (node); 1205 1205 1206 + ctx_flush_and_put(ctx, &ts); 1206 1207 return count; 1207 1208 } 1208 1209 ··· 1251 1250 1252 1251 void tctx_task_work(struct callback_head *cb) 1253 1252 { 1254 - struct io_tw_state ts = {}; 1255 - struct io_ring_ctx *ctx = NULL; 1256 1253 struct io_uring_task *tctx = container_of(cb, struct io_uring_task, 1257 1254 task_work); 1258 1255 struct llist_node *node; ··· 1263 1264 1264 1265 node = llist_del_all(&tctx->task_list); 1265 1266 if (node) 1266 - count = handle_tw_list(llist_reverse_order(node), &ctx, &ts); 1267 - 1268 - ctx_flush_and_put(ctx, &ts); 1267 + count = handle_tw_list(llist_reverse_order(node)); 1269 1268 1270 1269 /* relaxed read is enough as only the task itself sets ->in_cancel */ 1271 1270 if (unlikely(atomic_read(&tctx->in_cancel)))