diff mbox series

[v2,1/3] io_uring: Create a helper to return the SQE size

Message ID 20230421114440.3343473-2-leitao@debian.org (mailing list archive)
State New
Headers show
Series io_uring: Pass the whole sqe to commands | expand

Commit Message

Breno Leitao April 21, 2023, 11:44 a.m. UTC
Create a simple helper that returns the size of the SQE. The SQE could
have two size, depending of the flags.

If IO_URING_SETUP_SQE128 flag is set, then return a double SQE,
otherwise returns the sizeof of io_uring_sqe (64 bytes).

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 io_uring/io_uring.h | 3 +++
 1 file changed, 3 insertions(+)

Comments

Christoph Hellwig April 24, 2023, 7:19 a.m. UTC | #1
On Fri, Apr 21, 2023 at 04:44:38AM -0700, Breno Leitao wrote:
> +#define uring_sqe_size(ctx) \
> +	((1 + !!(ctx->flags & IORING_SETUP_SQE128)) * sizeof(struct io_uring_sqe))

Please turn this into an actually readable inline function:

/*
 * IORING_SETUP_SQE128 contexts allocate twice the normal SQE size for each
 * slot.
 */
static inline size_t uring_sqe_size(struct io_ring_ctx *ctx)
{
	if (ctx->flags & IORING_SETUP_SQE128)
		return 2 * sizeof(struct io_uring_sqe);
	return sizeof(struct io_uring_sqe);
}
diff mbox series

Patch

diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h
index 25515d69d205..25597a771929 100644
--- a/io_uring/io_uring.h
+++ b/io_uring/io_uring.h
@@ -394,4 +394,7 @@  static inline void io_req_queue_tw_complete(struct io_kiocb *req, s32 res)
 	io_req_task_work_add(req);
 }
 
+#define uring_sqe_size(ctx) \
+	((1 + !!(ctx->flags & IORING_SETUP_SQE128)) * sizeof(struct io_uring_sqe))
+
 #endif