public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH for-next 3/4] io_uring: consistent naming for inline completion
Date: Sat, 18 Jun 2022 13:27:26 +0100	[thread overview]
Message-ID: <ce36284d656e44966b3c4ddf148a18c8dd643052.1655553990.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

Improve naming of the inline/deferred completion helper so it's
consistent with it's *_post counterpart. Add some comments and extra
lockdeps to ensure the locking is done right.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 io_uring/io_uring.c |  4 ++--
 io_uring/io_uring.h | 10 +++++++++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 430e65494989..3a955044f2f7 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -1391,7 +1391,7 @@ void io_req_task_complete(struct io_kiocb *req, bool *locked)
 	}
 
 	if (*locked)
-		io_req_add_compl_list(req);
+		io_req_complete_defer(req);
 	else
 		io_req_complete_post(req);
 }
@@ -1659,7 +1659,7 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)
 
 	if (ret == IOU_OK) {
 		if (issue_flags & IO_URING_F_COMPLETE_DEFER)
-			io_req_add_compl_list(req);
+			io_req_complete_defer(req);
 		else
 			io_req_complete_post(req);
 	} else if (ret != IOU_ISSUE_SKIP_COMPLETE)
diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h
index 5eaa01c4697c..362a42471154 100644
--- a/io_uring/io_uring.h
+++ b/io_uring/io_uring.h
@@ -168,10 +168,18 @@ static inline void io_tw_lock(struct io_ring_ctx *ctx, bool *locked)
 	}
 }
 
-static inline void io_req_add_compl_list(struct io_kiocb *req)
+/*
+ * Don't complete immediately but use deferred completion infrastructure.
+ * Protected by ->uring_lock and can only be used either with
+ * IO_URING_F_COMPLETE_DEFER or inside a tw handler holding the mutex.
+ */
+static inline void io_req_complete_defer(struct io_kiocb *req)
+	__must_hold(&req->ctx->uring_lock)
 {
 	struct io_submit_state *state = &req->ctx->submit_state;
 
+	lockdep_assert_held(&req->ctx->uring_lock);
+
 	if (!(req->flags & REQ_F_CQE_SKIP))
 		state->flush_cqes = true;
 	wq_list_add_tail(&req->comp_list, &state->compl_reqs);
-- 
2.36.1


  parent reply	other threads:[~2022-06-18 12:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-18 12:27 [PATCH for-next 0/4] simple cleanups Pavel Begunkov
2022-06-18 12:27 ` [PATCH for-next 1/4] io_uring: opcode independent fixed buf import Pavel Begunkov
2022-06-18 12:27 ` [PATCH for-next 2/4] io_uring: move io_import_fixed() Pavel Begunkov
2022-06-18 12:27 ` Pavel Begunkov [this message]
2022-06-18 12:27 ` [PATCH for-next 4/4] io_uring: add an warn_once for poll_find Pavel Begunkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ce36284d656e44966b3c4ddf148a18c8dd643052.1655553990.git.asml.silence@gmail.com \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox