Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Pavel Begunkov and committed by
Jens Axboe
4aaa9bc4 2647e2ec

+21
+8
include/uapi/linux/io_uring/query.h
··· 19 19 enum { 20 20 IO_URING_QUERY_OPCODES = 0, 21 21 IO_URING_QUERY_ZCRX = 1, 22 + IO_URING_QUERY_SCQ = 2, 22 23 23 24 __IO_URING_QUERY_MAX, 24 25 }; ··· 56 55 /* The alignment for the header */ 57 56 __u32 rq_hdr_alignment; 58 57 __u64 __resv2; 58 + }; 59 + 60 + struct io_uring_query_scq { 61 + /* The SQ/CQ rings header size */ 62 + __u64 hdr_size; 63 + /* The alignment for the header */ 64 + __u64 hdr_alignment; 59 65 }; 60 66 61 67 #endif
+13
io_uring/query.c
··· 9 9 union io_query_data { 10 10 struct io_uring_query_opcode opcodes; 11 11 struct io_uring_query_zcrx zcrx; 12 + struct io_uring_query_scq scq; 12 13 }; 13 14 14 15 #define IO_MAX_QUERY_SIZE sizeof(union io_query_data) ··· 44 43 return sizeof(*e); 45 44 } 46 45 46 + static ssize_t io_query_scq(union io_query_data *data) 47 + { 48 + struct io_uring_query_scq *e = &data->scq; 49 + 50 + e->hdr_size = sizeof(struct io_rings); 51 + e->hdr_alignment = SMP_CACHE_BYTES; 52 + return sizeof(*e); 53 + } 54 + 47 55 static int io_handle_query_entry(struct io_ring_ctx *ctx, 48 56 union io_query_data *data, void __user *uhdr, 49 57 u64 *next_entry) ··· 83 73 break; 84 74 case IO_URING_QUERY_ZCRX: 85 75 ret = io_query_zcrx(data); 76 + break; 77 + case IO_URING_QUERY_SCQ: 78 + ret = io_query_scq(data); 86 79 break; 87 80 } 88 81