public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH for-next 0/2] random for-next io_uring patches
@ 2022-11-24 19:46 Pavel Begunkov
  2022-11-24 19:46 ` [PATCH for-next 1/2] io_uring: don't use complete_post in kbuf Pavel Begunkov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Pavel Begunkov @ 2022-11-24 19:46 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

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(-)

-- 
2.38.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH for-next 1/2] io_uring: don't use complete_post in kbuf
  2022-11-24 19:46 [PATCH for-next 0/2] random for-next io_uring patches Pavel Begunkov
@ 2022-11-24 19:46 ` Pavel Begunkov
  2022-11-24 19:46 ` [PATCH for-next 2/2] io_uring: keep unlock_post inlined in hot path Pavel Begunkov
  2022-11-25 13:13 ` [PATCH for-next 0/2] random for-next io_uring patches Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2022-11-24 19:46 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

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.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 io_uring/kbuf.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c
index e8150ed637d8..4a6401080c1f 100644
--- a/io_uring/kbuf.c
+++ b/io_uring/kbuf.c
@@ -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)
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH for-next 2/2] io_uring: keep unlock_post inlined in hot path
  2022-11-24 19:46 [PATCH for-next 0/2] random for-next io_uring patches Pavel Begunkov
  2022-11-24 19:46 ` [PATCH for-next 1/2] io_uring: don't use complete_post in kbuf Pavel Begunkov
@ 2022-11-24 19:46 ` Pavel Begunkov
  2022-11-25 13:13 ` [PATCH for-next 0/2] random for-next io_uring patches Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2022-11-24 19:46 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

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.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 io_uring/io_uring.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 164904e7da25..e67bc906a9d0 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -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);
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH for-next 0/2] random for-next io_uring patches
  2022-11-24 19:46 [PATCH for-next 0/2] random for-next io_uring patches Pavel Begunkov
  2022-11-24 19:46 ` [PATCH for-next 1/2] io_uring: don't use complete_post in kbuf Pavel Begunkov
  2022-11-24 19:46 ` [PATCH for-next 2/2] io_uring: keep unlock_post inlined in hot path Pavel Begunkov
@ 2022-11-25 13:13 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2022-11-25 13:13 UTC (permalink / raw)
  To: io-uring, Pavel Begunkov

On Thu, 24 Nov 2022 19:46:39 +0000, Pavel Begunkov wrote:
> 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,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-25 13:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-24 19:46 [PATCH for-next 0/2] random for-next io_uring patches Pavel Begunkov
2022-11-24 19:46 ` [PATCH for-next 1/2] io_uring: don't use complete_post in kbuf Pavel Begunkov
2022-11-24 19:46 ` [PATCH for-next 2/2] io_uring: keep unlock_post inlined in hot path Pavel Begunkov
2022-11-25 13:13 ` [PATCH for-next 0/2] random for-next io_uring patches Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox