Skip to contentSkip to conversation

io_uring: use local ctx consistently

PATCH Superseded Yang Xiuwei 2 participants 2 messages Apr 1 io_uring

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 io_uring: use local ctx consistently

Use the struct io_ring_ctx *ctx already held in io_buffer_select(), io_send_zc_prep(), and io_timeout_fn() for submit lock/unlock, compat checks, and cq_timeouts accounting, instead of repeating req->ctx.

No functional change.

---
 io_uring/kbuf.c    | 4 ++--
 io_uring/net.c     | 2 +-
 io_uring/timeout.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)
io_uring/kbuf.c +2 -2
index 5257b3aad395..8da2ff798170 100644
@@ -230,7 +230,7 @@ struct io_br_sel io_buffer_select(struct io_kiocb *req, size_t *len,
 	struct io_br_sel sel = { };
 	struct io_buffer_list *bl;
 
-	io_ring_submit_lock(req->ctx, issue_flags);
+	io_ring_submit_lock(ctx, issue_flags);
 
 	bl = io_buffer_get_list(ctx, buf_group);
 	if (likely(bl)) {
@@ -239,7 +239,7 @@ struct io_br_sel io_buffer_select(struct io_kiocb *req, size_t *len,
 		else
 			sel.addr = io_provided_buffer_select(req, len, bl);
 	}
-	io_ring_submit_unlock(req->ctx, issue_flags);
+	io_ring_submit_unlock(ctx, issue_flags);
 	return sel;
 }
 
io_uring/net.c +1 -1
index d27adbe3f20b..338832488483 100644
@@ -1366,7 +1366,7 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 	if (zc->msg_flags & MSG_DONTWAIT)
 		req->flags |= REQ_F_NOWAIT;
 
-	if (io_is_compat(req->ctx))
+	if (io_is_compat(ctx))
 		zc->msg_flags |= MSG_CMSG_COMPAT;
 
 	iomsg = io_msg_alloc_async(req);
io_uring/timeout.c +2 -2
index cb61d4862fc6..798d88940d14 100644
@@ -265,8 +265,8 @@ static enum hrtimer_restart io_timeout_fn(struct hrtimer *timer)
 
 	raw_spin_lock_irqsave(&ctx->timeout_lock, flags);
 	list_del_init(&timeout->list);
-	atomic_set(&req->ctx->cq_timeouts,
-		atomic_read(&req->ctx->cq_timeouts) + 1);
+	atomic_set(&ctx->cq_timeouts,
+		atomic_read(&ctx->cq_timeouts) + 1);
 	raw_spin_unlock_irqrestore(&ctx->timeout_lock, flags);
 
 	if (!(data->flags & IORING_TIMEOUT_ETIME_SUCCESS))
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 6 lines · Yang Xiuwei

Use the struct io_ring_ctx *ctx already held in io_buffer_select(), io_send_zc_prep(), and io_timeout_fn() for submit lock/unlock, compat checks, and cq_timeouts accounting, instead of repeating req->ctx.

No functional change.

Please check for-7.1/io_uring first, most/all of these are already done.

Signature · 1 line
Jens Axboe