io_uring: don't pass ctx to tw add remote helper
authorPavel Begunkov <asml.silence@gmail.com>
Fri, 28 Mar 2025 23:11:51 +0000 (23:11 +0000)
committerJens Axboe <axboe@kernel.dk>
Fri, 28 Mar 2025 23:14:01 +0000 (17:14 -0600)
Unlike earlier versions, io_msg_remote_post() creates a valid request
with a proper context, so don't pass a context to
io_req_task_work_add_remote() explicitly but derive it from the request.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/721f51cf34996d98b48f0bfd24ad40aa2730167e.1743190078.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c
io_uring/io_uring.h
io_uring/msg_ring.c

index 3ba49c6283378b3c0f1525700cd32482184daed6..e4484a03e033e0a7cee6e37ad796657aca40e22e 100644 (file)
@@ -1141,10 +1141,9 @@ void tctx_task_work(struct callback_head *cb)
        WARN_ON_ONCE(ret);
 }
 
-static inline void io_req_local_work_add(struct io_kiocb *req,
-                                        struct io_ring_ctx *ctx,
-                                        unsigned flags)
+static void io_req_local_work_add(struct io_kiocb *req, unsigned flags)
 {
+       struct io_ring_ctx *ctx = req->ctx;
        unsigned nr_wait, nr_tw, nr_tw_prev;
        struct llist_node *head;
 
@@ -1239,17 +1238,16 @@ static void io_req_normal_work_add(struct io_kiocb *req)
 void __io_req_task_work_add(struct io_kiocb *req, unsigned flags)
 {
        if (req->ctx->flags & IORING_SETUP_DEFER_TASKRUN)
-               io_req_local_work_add(req, req->ctx, flags);
+               io_req_local_work_add(req, flags);
        else
                io_req_normal_work_add(req);
 }
 
-void io_req_task_work_add_remote(struct io_kiocb *req, struct io_ring_ctx *ctx,
-                                unsigned flags)
+void io_req_task_work_add_remote(struct io_kiocb *req, unsigned flags)
 {
-       if (WARN_ON_ONCE(!(ctx->flags & IORING_SETUP_DEFER_TASKRUN)))
+       if (WARN_ON_ONCE(!(req->ctx->flags & IORING_SETUP_DEFER_TASKRUN)))
                return;
-       io_req_local_work_add(req, ctx, flags);
+       __io_req_task_work_add(req, flags);
 }
 
 static void __cold io_move_task_work_from_local(struct io_ring_ctx *ctx)
index 87f8831302869d6c1dfa1b05b6ac7438ff83a501..e4050b2d0821f529585ab0ba10f8cd383acfa34a 100644 (file)
@@ -89,8 +89,7 @@ struct file *io_file_get_fixed(struct io_kiocb *req, int fd,
                               unsigned issue_flags);
 
 void __io_req_task_work_add(struct io_kiocb *req, unsigned flags);
-void io_req_task_work_add_remote(struct io_kiocb *req, struct io_ring_ctx *ctx,
-                                unsigned flags);
+void io_req_task_work_add_remote(struct io_kiocb *req, unsigned flags);
 void io_req_task_queue(struct io_kiocb *req);
 void io_req_task_complete(struct io_kiocb *req, io_tw_token_t tw);
 void io_req_task_queue_fail(struct io_kiocb *req, int ret);
index 6c51b942d020d0b13dddc29f1d7939073099fdb7..50a958e9c92129ceb8e280b7f56a17b2c49fdefc 100644 (file)
@@ -100,7 +100,7 @@ static int io_msg_remote_post(struct io_ring_ctx *ctx, struct io_kiocb *req,
        req->ctx = ctx;
        req->tctx = NULL;
        req->io_task_work.func = io_msg_tw_complete;
-       io_req_task_work_add_remote(req, ctx, IOU_F_TWQ_LAZY_WAKE);
+       io_req_task_work_add_remote(req, IOU_F_TWQ_LAZY_WAKE);
        return 0;
 }