public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jens Axboe <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>
Subject: [PATCH 3/4] io_uring: add IOSQE2_POLL_FIRST flag
Date: Tue, 26 Apr 2022 12:33:42 -0600	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

For some operations, the application fully expects that no data or space
is available, and that the request will be punted to our poll handler
after the initial transfer attempt. For this case, it's a potentially big
waste of time to first attempt the operation, only to get -EAGAIN and
need to arm poll.

Add IOSQE2_POLL_FIRST for this case, allowing the application to request
that the handler checks poll first before attempting the operation.

Signed-off-by: Jens Axboe <[email protected]>
---
 fs/io_uring.c                 |  5 ++++-
 include/uapi/linux/io_uring.h | 11 +++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 06afe4db5a9a..eb5f77bde98d 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -111,7 +111,7 @@
 			IOSQE_IO_DRAIN | IOSQE_CQE_SKIP_SUCCESS | \
 			IOSQE_FLAGS2)
 
-#define SQE_VALID_FLAGS2	0
+#define SQE_VALID_FLAGS2	(IOSQE2_POLL_FIRST)
 
 #define IO_REQ_CLEAN_FLAGS (REQ_F_BUFFER_SELECTED | REQ_F_NEED_CLEANUP | \
 				REQ_F_POLLED | REQ_F_CREDS | REQ_F_ASYNC_DATA)
@@ -792,6 +792,7 @@ enum {
 	REQ_F_BUFFER_SELECT_BIT	= IOSQE_BUFFER_SELECT_BIT,
 	REQ_F_CQE_SKIP_BIT	= IOSQE_CQE_SKIP_SUCCESS_BIT,
 	REQ_F_FLAGS2_BIT	= IOSQE_FLAGS2_BIT,
+	REQ_F_POLL_FIRST_BIT	= IOSQE_FLAGS2_BIT + 1,
 
 	/* first bits are taken by user flags, shift it to not overlap */
 	REQ_F_FAIL_BIT		= 9,
@@ -837,6 +838,8 @@ enum {
 	REQ_F_CQE_SKIP		= BIT(REQ_F_CQE_SKIP_BIT),
 	/* IOSQE_FLAGS2 */
 	REQ_F_FLAGS2		= BIT(REQ_F_FLAGS2_BIT),
+	/* IOSQE2_POLL_FIRST */
+	REQ_F_POLL_FIRST	= BIT(REQ_F_POLL_FIRST_BIT),
 
 	/* fail rest of links */
 	REQ_F_FAIL		= BIT(REQ_F_FAIL_BIT),
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index 622f6e27a444..fe5d8cae7e7d 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -66,6 +66,7 @@ struct io_uring_sqe {
 	__u64	__pad2[2];
 };
 
+/* sqe->flags */
 enum {
 	IOSQE_FIXED_FILE_BIT,
 	IOSQE_IO_DRAIN_BIT,
@@ -77,6 +78,11 @@ enum {
 	IOSQE_FLAGS2_BIT,
 };
 
+/* sqe->flags2, if IOSQE_FLAGS2 is set in sqe->flags */
+enum {
+	IOSQE2_POLL_FIRST_BIT,
+};
+
 /*
  * sqe->flags
  */
@@ -97,6 +103,11 @@ enum {
 /* flags2 is valid and set */
 #define IOSQE_FLAGS2		(1U << IOSQE_FLAGS2_BIT)
 
+/*
+ * sqe->flags2
+ */
+#define IOSQE2_POLL_FIRST	(1U << IOSQE2_POLL_FIRST_BIT)
+
 /*
  * io_uring_setup() flags
  */
-- 
2.35.1



  parent reply	other threads:[~2022-04-26 18:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-26 18:33 [PATCHSET RFC 0/4] Add support for IOSQE2_POLL_FIRST Jens Axboe
2022-04-26 18:33 ` [PATCH 1/4] io_uring: check IOPOLL/ioprio support upfront Jens Axboe
2022-04-26 18:33 ` [PATCH 2/4] io_uring: add flags2 variable Jens Axboe
2022-04-26 18:33 ` Jens Axboe [this message]
2022-04-26 18:33 ` [PATCH 4/4] io_uring: wire up IOSQE2_POLL_FIRST for send/sendmsg and recv/recvmsg Jens Axboe

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 \
    [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