public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring: save repeated issue_flags
@ 2023-12-05 21:55 Keith Busch
  2023-12-05 22:00 ` Jens Axboe
  0 siblings, 1 reply; 8+ messages in thread
From: Keith Busch @ 2023-12-05 21:55 UTC (permalink / raw)
  To: io-uring; +Cc: asml.silence, Keith Busch, Jens Axboe

From: Keith Busch <[email protected]>

No need to rebuild the issue_flags on every IO: they're always the same.

Suggested-by: Jens Axboe <[email protected]>
Signed-off-by: Keith Busch <[email protected]>
---
 include/linux/io_uring_types.h |  1 +
 io_uring/io_uring.c            | 15 ++++++++++++---
 io_uring/uring_cmd.c           |  8 +-------
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/include/linux/io_uring_types.h b/include/linux/io_uring_types.h
index bebab36abce89..dd192d828f463 100644
--- a/include/linux/io_uring_types.h
+++ b/include/linux/io_uring_types.h
@@ -228,6 +228,7 @@ struct io_ring_ctx {
 	/* const or read-mostly hot data */
 	struct {
 		unsigned int		flags;
+		unsigned int		issue_flags;
 		unsigned int		drain_next: 1;
 		unsigned int		restricted: 1;
 		unsigned int		off_timeout_used: 1;
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 1d254f2c997de..a338e3660ecb8 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -3975,11 +3975,20 @@ static __cold int io_uring_create(unsigned entries, struct io_uring_params *p,
 	 * polling again, they can rely on io_sq_thread to do polling
 	 * work, which can reduce cpu usage and uring_lock contention.
 	 */
-	if (ctx->flags & IORING_SETUP_IOPOLL &&
-	    !(ctx->flags & IORING_SETUP_SQPOLL))
-		ctx->syscall_iopoll = 1;
+	if (ctx->flags & IORING_SETUP_IOPOLL) {
+		ctx->issue_flags |= IO_URING_F_SQE128;
+		if (!(ctx->flags & IORING_SETUP_SQPOLL))
+			ctx->syscall_iopoll = 1;
+	}
 
 	ctx->compat = in_compat_syscall();
+	if (ctx->compat)
+		ctx->issue_flags |= IO_URING_F_COMPAT;
+	if (ctx->flags & IORING_SETUP_SQE128)
+		ctx->issue_flags |= IO_URING_F_SQE128;
+	if (ctx->flags & IORING_SETUP_CQE32)
+		ctx->issue_flags |= IO_URING_F_CQE32;
+
 	if (!ns_capable_noaudit(&init_user_ns, CAP_IPC_LOCK))
 		ctx->user = get_uid(current_user());
 
diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c
index 8a38b9f75d841..dbc0bfbfd0f05 100644
--- a/io_uring/uring_cmd.c
+++ b/io_uring/uring_cmd.c
@@ -158,19 +158,13 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)
 	if (ret)
 		return ret;
 
-	if (ctx->flags & IORING_SETUP_SQE128)
-		issue_flags |= IO_URING_F_SQE128;
-	if (ctx->flags & IORING_SETUP_CQE32)
-		issue_flags |= IO_URING_F_CQE32;
-	if (ctx->compat)
-		issue_flags |= IO_URING_F_COMPAT;
 	if (ctx->flags & IORING_SETUP_IOPOLL) {
 		if (!file->f_op->uring_cmd_iopoll)
 			return -EOPNOTSUPP;
-		issue_flags |= IO_URING_F_IOPOLL;
 		req->iopoll_completed = 0;
 	}
 
+	issue_flags |= ctx->issue_flags;
 	ret = file->f_op->uring_cmd(ioucmd, issue_flags);
 	if (ret == -EAGAIN) {
 		if (!req_has_async_data(req)) {
-- 
2.34.1


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

end of thread, other threads:[~2023-12-06  1:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-05 21:55 [PATCH] io_uring: save repeated issue_flags Keith Busch
2023-12-05 22:00 ` Jens Axboe
2023-12-05 23:02   ` Keith Busch
2023-12-05 23:11     ` Jens Axboe
2023-12-06  1:31       ` Pavel Begunkov
2023-12-06  1:26   ` Pavel Begunkov
2023-12-06  1:41     ` Jens Axboe
2023-12-06  1:51       ` Pavel Begunkov

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