summaryrefslogtreecommitdiff
path: root/io_uring/query.c
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2025-11-13 10:48:58 +0000
committerJens Axboe <axboe@kernel.dk>2025-11-13 11:17:36 -0700
commit4aaa9bc4d5921363490d95fe66c4db086a915799 (patch)
treed441dc5b4d430263bb9c317a2d89b41e715a9a8d /io_uring/query.c
parent2647e2ecc096d2330d6b6a34a3a1f0a99828c14c (diff)
io_uring/query: introduce rings info query
Same problem as with zcrx in the previous patch, the user needs to know SQ/CQ header sizes to allocated memory before setup to use it for user provided rings, i.e. IORING_SETUP_NO_MMAP, however that information is only returned after registration, hence the user is guessing kernel implementation details. Return the header size and alignment, which is split with the same motivation, to allow the user to know the real structure size without alignment in case there will be more flexible placement schemes in the future. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/query.c')
-rw-r--r--io_uring/query.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/io_uring/query.c b/io_uring/query.c
index 6f9fa5153903..e61b6221f87f 100644
--- a/io_uring/query.c
+++ b/io_uring/query.c
@@ -9,6 +9,7 @@
union io_query_data {
struct io_uring_query_opcode opcodes;
struct io_uring_query_zcrx zcrx;
+ struct io_uring_query_scq scq;
};
#define IO_MAX_QUERY_SIZE sizeof(union io_query_data)
@@ -43,6 +44,15 @@ static ssize_t io_query_zcrx(union io_query_data *data)
return sizeof(*e);
}
+static ssize_t io_query_scq(union io_query_data *data)
+{
+ struct io_uring_query_scq *e = &data->scq;
+
+ e->hdr_size = sizeof(struct io_rings);
+ e->hdr_alignment = SMP_CACHE_BYTES;
+ return sizeof(*e);
+}
+
static int io_handle_query_entry(struct io_ring_ctx *ctx,
union io_query_data *data, void __user *uhdr,
u64 *next_entry)
@@ -74,6 +84,9 @@ static int io_handle_query_entry(struct io_ring_ctx *ctx,
case IO_URING_QUERY_ZCRX:
ret = io_query_zcrx(data);
break;
+ case IO_URING_QUERY_SCQ:
+ ret = io_query_scq(data);
+ break;
}
if (ret >= 0) {