]> Gentwo Git Trees - linux/.git/commitdiff
io_uring/query: introduce zcrx query
authorPavel Begunkov <asml.silence@gmail.com>
Thu, 13 Nov 2025 10:48:57 +0000 (10:48 +0000)
committerJens Axboe <axboe@kernel.dk>
Thu, 13 Nov 2025 18:17:36 +0000 (11:17 -0700)
Add a new query type IO_URING_QUERY_ZCRX returning the user some basic
information about the interface, which includes allowed flags for areas
and registration and supported IORING_REGISTER_ZCRX_CTRL subcodes.

There is also a chicken-egg problem with user provided refill queue
memory, where offsets and size information is returned after
registration, but to properly allocate memory you need to know it
beforehand, which is why the userspace currently has to guess the RQ
headers size and severely overestimates it. Return the size information.
It's split into "size" and "alignment" fields because for default
placement modes the user is interested in the aligned size, however if
it gets support for more flexible placement, it'll need to only know the
actual header size.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/uapi/linux/io_uring/query.h
io_uring/query.c

index 3539ccbfd0644ce1a0b289513510e6584d1784a2..fc0cb1580e47370aea6a4c463f7becff41502cf6 100644 (file)
@@ -18,6 +18,7 @@ struct io_uring_query_hdr {
 
 enum {
        IO_URING_QUERY_OPCODES                  = 0,
+       IO_URING_QUERY_ZCRX                     = 1,
 
        __IO_URING_QUERY_MAX,
 };
@@ -41,4 +42,19 @@ struct io_uring_query_opcode {
        __u32   __pad;
 };
 
+struct io_uring_query_zcrx {
+       /* Bitmask of supported ZCRX_REG_* flags, */
+       __u64 register_flags;
+       /* Bitmask of all supported IORING_ZCRX_AREA_* flags */
+       __u64 area_flags;
+       /* The number of supported ZCRX_CTRL_* opcodes */
+       __u32 nr_ctrl_opcodes;
+       __u32 __resv1;
+       /* The refill ring header size */
+       __u32 rq_hdr_size;
+       /* The alignment for the header */
+       __u32 rq_hdr_alignment;
+       __u64 __resv2;
+};
+
 #endif
index e1435cdc2665e8feec2e70b1b50da90528a36368..6f9fa5153903f8552a02502040a5b26e92bc5375 100644 (file)
@@ -4,9 +4,11 @@
 
 #include "query.h"
 #include "io_uring.h"
+#include "zcrx.h"
 
 union io_query_data {
        struct io_uring_query_opcode opcodes;
+       struct io_uring_query_zcrx zcrx;
 };
 
 #define IO_MAX_QUERY_SIZE              sizeof(union io_query_data)
@@ -27,6 +29,20 @@ static ssize_t io_query_ops(union io_query_data *data)
        return sizeof(*e);
 }
 
+static ssize_t io_query_zcrx(union io_query_data *data)
+{
+       struct io_uring_query_zcrx *e = &data->zcrx;
+
+       e->register_flags = ZCRX_REG_IMPORT;
+       e->area_flags = IORING_ZCRX_AREA_DMABUF;
+       e->nr_ctrl_opcodes = __ZCRX_CTRL_LAST;
+       e->rq_hdr_size = sizeof(struct io_uring);
+       e->rq_hdr_alignment = L1_CACHE_BYTES;
+       e->__resv1 = 0;
+       e->__resv2 = 0;
+       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)
@@ -55,6 +71,9 @@ static int io_handle_query_entry(struct io_ring_ctx *ctx,
        case IO_URING_QUERY_OPCODES:
                ret = io_query_ops(data);
                break;
+       case IO_URING_QUERY_ZCRX:
+               ret = io_query_zcrx(data);
+               break;
        }
 
        if (ret >= 0) {