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/cmd: expose iowq to cmds

When an io_uring request needs blocking context we offload it to the
io_uring's thread pool called io-wq. We can get there off ->uring_cmd
by returning -EAGAIN, but there is no straightforward way of doing that
from an asynchronous callback. Add a helper that would transfer a
command to a blocking context.

Note, we do an extra hop via task_work before io_queue_iowq(), that's a
limitation of io_uring infra we have that can likely be lifted later
if that would ever become a problem.

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

authored by

Pavel Begunkov and committed by
Jens Axboe
6746ee4c 6d0f8dcb

+25
+6
include/linux/io_uring/cmd.h
··· 48 48 void io_uring_cmd_mark_cancelable(struct io_uring_cmd *cmd, 49 49 unsigned int issue_flags); 50 50 51 + /* Execute the request from a blocking context */ 52 + void io_uring_cmd_issue_blocking(struct io_uring_cmd *ioucmd); 53 + 51 54 #else 52 55 static inline int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw, 53 56 struct iov_iter *iter, void *ioucmd) ··· 68 65 } 69 66 static inline void io_uring_cmd_mark_cancelable(struct io_uring_cmd *cmd, 70 67 unsigned int issue_flags) 68 + { 69 + } 70 + static inline void io_uring_cmd_issue_blocking(struct io_uring_cmd *ioucmd) 71 71 { 72 72 } 73 73 #endif
+11
io_uring/io_uring.c
··· 533 533 io_queue_linked_timeout(link); 534 534 } 535 535 536 + static void io_req_queue_iowq_tw(struct io_kiocb *req, struct io_tw_state *ts) 537 + { 538 + io_queue_iowq(req); 539 + } 540 + 541 + void io_req_queue_iowq(struct io_kiocb *req) 542 + { 543 + req->io_task_work.func = io_req_queue_iowq_tw; 544 + io_req_task_work_add(req); 545 + } 546 + 536 547 static __cold void io_queue_deferred(struct io_ring_ctx *ctx) 537 548 { 538 549 while (!list_empty(&ctx->defer_list)) {
+1
io_uring/io_uring.h
··· 94 94 95 95 int io_ring_add_registered_file(struct io_uring_task *tctx, struct file *file, 96 96 int start, int end); 97 + void io_req_queue_iowq(struct io_kiocb *req); 97 98 98 99 int io_poll_issue(struct io_kiocb *req, struct io_tw_state *ts); 99 100 int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr);
+7
io_uring/uring_cmd.c
··· 277 277 } 278 278 EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed); 279 279 280 + void io_uring_cmd_issue_blocking(struct io_uring_cmd *ioucmd) 281 + { 282 + struct io_kiocb *req = cmd_to_io_kiocb(ioucmd); 283 + 284 + io_req_queue_iowq(req); 285 + } 286 + 280 287 static inline int io_uring_cmd_getsockopt(struct socket *sock, 281 288 struct io_uring_cmd *cmd, 282 289 unsigned int issue_flags)