* [PATCH 0/2] zcrx and SQ/CQ queries
@ 2025-11-13 10:48 Pavel Begunkov
2025-11-13 10:48 ` [PATCH 1/2] io_uring/query: introduce zcrx query Pavel Begunkov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Pavel Begunkov @ 2025-11-13 10:48 UTC (permalink / raw)
To: io-uring; +Cc: asml.silence
Note: depends on the 6.19 zcrx updates, and based on top of a
recent 6.18 query patch.
Introduce zcrx and SQ/CQ layout queries. The former returns what
zcrx features are available. And both return the ring size
information to help with allocation size calculation for user
provided rings like IORING_SETUP_NO_MMAP and.
IORING_MEM_REGION_TYPE_USER
Pavel Begunkov (2):
io_uring/query: introduce zcrx query
io_uring/query: introduce rings info query
include/uapi/linux/io_uring/query.h | 24 ++++++++++++++++++++++
io_uring/query.c | 32 +++++++++++++++++++++++++++++
2 files changed, 56 insertions(+)
--
2.49.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] io_uring/query: introduce zcrx query
2025-11-13 10:48 [PATCH 0/2] zcrx and SQ/CQ queries Pavel Begunkov
@ 2025-11-13 10:48 ` Pavel Begunkov
2025-11-13 10:48 ` [PATCH 2/2] io_uring/query: introduce rings info query Pavel Begunkov
2025-11-13 18:38 ` [PATCH 0/2] zcrx and SQ/CQ queries Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2025-11-13 10:48 UTC (permalink / raw)
To: io-uring; +Cc: asml.silence
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>
---
include/uapi/linux/io_uring/query.h | 16 ++++++++++++++++
io_uring/query.c | 19 +++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/include/uapi/linux/io_uring/query.h b/include/uapi/linux/io_uring/query.h
index 3539ccbfd064..fc0cb1580e47 100644
--- a/include/uapi/linux/io_uring/query.h
+++ b/include/uapi/linux/io_uring/query.h
@@ -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
diff --git a/io_uring/query.c b/io_uring/query.c
index e1435cdc2665..6f9fa5153903 100644
--- a/io_uring/query.c
+++ b/io_uring/query.c
@@ -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) {
--
2.49.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] io_uring/query: introduce rings info query
2025-11-13 10:48 [PATCH 0/2] zcrx and SQ/CQ queries Pavel Begunkov
2025-11-13 10:48 ` [PATCH 1/2] io_uring/query: introduce zcrx query Pavel Begunkov
@ 2025-11-13 10:48 ` Pavel Begunkov
2025-11-13 18:38 ` [PATCH 0/2] zcrx and SQ/CQ queries Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2025-11-13 10:48 UTC (permalink / raw)
To: io-uring; +Cc: asml.silence
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>
---
include/uapi/linux/io_uring/query.h | 8 ++++++++
io_uring/query.c | 13 +++++++++++++
2 files changed, 21 insertions(+)
diff --git a/include/uapi/linux/io_uring/query.h b/include/uapi/linux/io_uring/query.h
index fc0cb1580e47..2456e6c5ebb5 100644
--- a/include/uapi/linux/io_uring/query.h
+++ b/include/uapi/linux/io_uring/query.h
@@ -19,6 +19,7 @@ struct io_uring_query_hdr {
enum {
IO_URING_QUERY_OPCODES = 0,
IO_URING_QUERY_ZCRX = 1,
+ IO_URING_QUERY_SCQ = 2,
__IO_URING_QUERY_MAX,
};
@@ -57,4 +58,11 @@ struct io_uring_query_zcrx {
__u64 __resv2;
};
+struct io_uring_query_scq {
+ /* The SQ/CQ rings header size */
+ __u64 hdr_size;
+ /* The alignment for the header */
+ __u64 hdr_alignment;
+};
+
#endif
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) {
--
2.49.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] zcrx and SQ/CQ queries
2025-11-13 10:48 [PATCH 0/2] zcrx and SQ/CQ queries Pavel Begunkov
2025-11-13 10:48 ` [PATCH 1/2] io_uring/query: introduce zcrx query Pavel Begunkov
2025-11-13 10:48 ` [PATCH 2/2] io_uring/query: introduce rings info query Pavel Begunkov
@ 2025-11-13 18:38 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2025-11-13 18:38 UTC (permalink / raw)
To: io-uring, Pavel Begunkov
On Thu, 13 Nov 2025 10:48:56 +0000, Pavel Begunkov wrote:
> Note: depends on the 6.19 zcrx updates, and based on top of a
> recent 6.18 query patch.
>
> Introduce zcrx and SQ/CQ layout queries. The former returns what
> zcrx features are available. And both return the ring size
> information to help with allocation size calculation for user
> provided rings like IORING_SETUP_NO_MMAP and.
> IORING_MEM_REGION_TYPE_USER
>
> [...]
Applied, thanks!
[1/2] io_uring/query: introduce zcrx query
commit: 2647e2ecc096d2330d6b6a34a3a1f0a99828c14c
[2/2] io_uring/query: introduce rings info query
commit: 4aaa9bc4d5921363490d95fe66c4db086a915799
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-11-13 18:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-13 10:48 [PATCH 0/2] zcrx and SQ/CQ queries Pavel Begunkov
2025-11-13 10:48 ` [PATCH 1/2] io_uring/query: introduce zcrx query Pavel Begunkov
2025-11-13 10:48 ` [PATCH 2/2] io_uring/query: introduce rings info query Pavel Begunkov
2025-11-13 18:38 ` [PATCH 0/2] zcrx and SQ/CQ queries Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox