Skip to content

Commit ea91067

Browse files
isilenceaxboe
authored andcommitted
io_uring: don't pass ctx to tw add remote helper
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 <[email protected]> Link: https://lore.kernel.org/r/721f51cf34996d98b48f0bfd24ad40aa2730167e.1743190078.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 9cc0bbd commit ea91067

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

io_uring/io_uring.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,10 +1141,9 @@ void tctx_task_work(struct callback_head *cb)
11411141
WARN_ON_ONCE(ret);
11421142
}
11431143

1144-
static inline void io_req_local_work_add(struct io_kiocb *req,
1145-
struct io_ring_ctx *ctx,
1146-
unsigned flags)
1144+
static void io_req_local_work_add(struct io_kiocb *req, unsigned flags)
11471145
{
1146+
struct io_ring_ctx *ctx = req->ctx;
11481147
unsigned nr_wait, nr_tw, nr_tw_prev;
11491148
struct llist_node *head;
11501149

@@ -1239,17 +1238,16 @@ static void io_req_normal_work_add(struct io_kiocb *req)
12391238
void __io_req_task_work_add(struct io_kiocb *req, unsigned flags)
12401239
{
12411240
if (req->ctx->flags & IORING_SETUP_DEFER_TASKRUN)
1242-
io_req_local_work_add(req, req->ctx, flags);
1241+
io_req_local_work_add(req, flags);
12431242
else
12441243
io_req_normal_work_add(req);
12451244
}
12461245

1247-
void io_req_task_work_add_remote(struct io_kiocb *req, struct io_ring_ctx *ctx,
1248-
unsigned flags)
1246+
void io_req_task_work_add_remote(struct io_kiocb *req, unsigned flags)
12491247
{
1250-
if (WARN_ON_ONCE(!(ctx->flags & IORING_SETUP_DEFER_TASKRUN)))
1248+
if (WARN_ON_ONCE(!(req->ctx->flags & IORING_SETUP_DEFER_TASKRUN)))
12511249
return;
1252-
io_req_local_work_add(req, ctx, flags);
1250+
__io_req_task_work_add(req, flags);
12531251
}
12541252

12551253
static void __cold io_move_task_work_from_local(struct io_ring_ctx *ctx)

io_uring/io_uring.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ struct file *io_file_get_fixed(struct io_kiocb *req, int fd,
8989
unsigned issue_flags);
9090

9191
void __io_req_task_work_add(struct io_kiocb *req, unsigned flags);
92-
void io_req_task_work_add_remote(struct io_kiocb *req, struct io_ring_ctx *ctx,
93-
unsigned flags);
92+
void io_req_task_work_add_remote(struct io_kiocb *req, unsigned flags);
9493
void io_req_task_queue(struct io_kiocb *req);
9594
void io_req_task_complete(struct io_kiocb *req, io_tw_token_t tw);
9695
void io_req_task_queue_fail(struct io_kiocb *req, int ret);

io_uring/msg_ring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static int io_msg_remote_post(struct io_ring_ctx *ctx, struct io_kiocb *req,
100100
req->ctx = ctx;
101101
req->tctx = NULL;
102102
req->io_task_work.func = io_msg_tw_complete;
103-
io_req_task_work_add_remote(req, ctx, IOU_F_TWQ_LAZY_WAKE);
103+
io_req_task_work_add_remote(req, IOU_F_TWQ_LAZY_WAKE);
104104
return 0;
105105
}
106106

0 commit comments

Comments
 (0)