Skip to contentSkip to conversation

random for-next io_uring patches

PATCH Applied Pavel Begunkov 2 participants 4 messages Nov 24, 2022 – Nov 25, 2022 io_uring

lore
Share & tools
lore
#0 lore raw

cover random for-next io_uring patches

1/2 removes two spots io_req_complete_post() in favour of the generic infra. 2/2 inlines io_cq_unlock_post() back.

Pavel Begunkov (2):
io_uring: don't use complete_post in kbuf
io_uring: keep unlock_post inlined in hot path

 io_uring/io_uring.c | 11 +++++++++--
 io_uring/kbuf.c     | 14 +++++---------
 2 files changed, 14 insertions(+), 11 deletions(-)
Signature · 1 line
2.38.1
#1 lore raw

PATCH 1/2 io_uring: don't use complete_post in kbuf

Now we're handling IOPOLL completions more generically, get rid uses of _post() and send requests through the normal path. It may have some extra mertis performance wise, but we don't care much as there is a better interface for selected buffers.

---
 io_uring/kbuf.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
io_uring/kbuf.c +5 -9
index e8150ed637d8..4a6401080c1f 100644
@@ -306,14 +306,11 @@ int io_remove_buffers(struct io_kiocb *req, unsigned int issue_flags)
 		if (!bl->buf_nr_pages)
 			ret = __io_remove_buffers(ctx, bl, p->nbufs);
 	}
+	io_ring_submit_unlock(ctx, issue_flags);
 	if (ret < 0)
 		req_set_fail(req);
-
-	/* complete before unlock, IOPOLL may need the lock */
 	io_req_set_res(req, ret, 0);
-	io_req_complete_post(req, 0);
-	io_ring_submit_unlock(ctx, issue_flags);
-	return IOU_ISSUE_SKIP_COMPLETE;
+	return IOU_OK;
 }
 
 int io_provide_buffers_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
@@ -458,13 +455,12 @@ int io_provide_buffers(struct io_kiocb *req, unsigned int issue_flags)
 
 	ret = io_add_buffers(ctx, p, bl);
 err:
+	io_ring_submit_unlock(ctx, issue_flags);
+
 	if (ret < 0)
 		req_set_fail(req);
-	/* complete before unlock, IOPOLL may need the lock */
 	io_req_set_res(req, ret, 0);
-	io_req_complete_post(req, 0);
-	io_ring_submit_unlock(ctx, issue_flags);
-	return IOU_ISSUE_SKIP_COMPLETE;
+	return IOU_OK;
 }
 
 int io_register_pbuf_ring(struct io_ring_ctx *ctx, void __user *arg)
Signature · 1 line
2.38.1
#2 lore raw

PATCH 2/2 io_uring: keep unlock_post inlined in hot path

In reply to Pavel Begunkov

This partially reverts

6c16fe3c16bdc ("io_uring: kill io_cqring_ev_posted() and __io_cq_unlock_post()")

The redundancy of __io_cq_unlock_post() was always to keep it inlined into __io_submit_flush_completions(). Inline it back and rename with hope of clarifying the intention behind it.

---
 io_uring/io_uring.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
io_uring/io_uring.c +9 -2
index 164904e7da25..e67bc906a9d0 100644
@@ -582,7 +582,8 @@ void __io_commit_cqring_flush(struct io_ring_ctx *ctx)
 		io_eventfd_flush_signal(ctx);
 }
 
-void io_cq_unlock_post(struct io_ring_ctx *ctx)
+/* keep it inlined for io_submit_flush_completions() */
+static inline void io_cq_unlock_post_inline(struct io_ring_ctx *ctx)
 	__releases(ctx->completion_lock)
 {
 	io_commit_cqring(ctx);
@@ -592,6 +593,12 @@ void io_cq_unlock_post(struct io_ring_ctx *ctx)
 	io_cqring_wake(ctx);
 }
 
+void io_cq_unlock_post(struct io_ring_ctx *ctx)
+	__releases(ctx->completion_lock)
+{
+	io_cq_unlock_post_inline(ctx);
+}
+
 /* Returns true if there are no backlogged entries after the flush */
 static bool __io_cqring_overflow_flush(struct io_ring_ctx *ctx, bool force)
 {
@@ -1391,7 +1398,7 @@ static void __io_submit_flush_completions(struct io_ring_ctx *ctx)
 		if (!(req->flags & REQ_F_CQE_SKIP))
 			__io_fill_cqe_req(ctx, req);
 	}
-	io_cq_unlock_post(ctx);
+	io_cq_unlock_post_inline(ctx);
 
 	if (!wq_list_empty(&ctx->submit_state.compl_reqs)) {
 		io_free_batch_list(ctx, state->compl_reqs.first);
Signature · 1 line
2.38.1
maintainer Applied
#3 lore raw
In reply to Pavel Begunkov
Quoted 8 lines · Pavel Begunkov

1/2 removes two spots io_req_complete_post() in favour of the generic infra. 2/2 inlines io_cq_unlock_post() back.

Pavel Begunkov (2):
io_uring: don't use complete_post in kbuf
io_uring: keep unlock_post inlined in hot path

[...]

Applied, thanks!

[1/2] io_uring: don't use complete_post in kbuf

      commit: c3b490930dbe6a6c98d3820f445757ddec1efb08
[2/2] io_uring: keep unlock_post inlined in hot path
      commit: 5d772916855f593672de55c437925daccc8ecd73

Best regards,

Signature · 1 line
Jens Axboe