Skip to content

Commit 2647e2e

Browse files
isilenceaxboe
authored andcommitted
io_uring/query: introduce zcrx query
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>
1 parent d741c62 commit 2647e2e

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

include/uapi/linux/io_uring/query.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ struct io_uring_query_hdr {
1818

1919
enum {
2020
IO_URING_QUERY_OPCODES = 0,
21+
IO_URING_QUERY_ZCRX = 1,
2122

2223
__IO_URING_QUERY_MAX,
2324
};
@@ -41,4 +42,19 @@ struct io_uring_query_opcode {
4142
__u32 __pad;
4243
};
4344

45+
struct io_uring_query_zcrx {
46+
/* Bitmask of supported ZCRX_REG_* flags, */
47+
__u64 register_flags;
48+
/* Bitmask of all supported IORING_ZCRX_AREA_* flags */
49+
__u64 area_flags;
50+
/* The number of supported ZCRX_CTRL_* opcodes */
51+
__u32 nr_ctrl_opcodes;
52+
__u32 __resv1;
53+
/* The refill ring header size */
54+
__u32 rq_hdr_size;
55+
/* The alignment for the header */
56+
__u32 rq_hdr_alignment;
57+
__u64 __resv2;
58+
};
59+
4460
#endif

io_uring/query.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
#include "query.h"
66
#include "io_uring.h"
7+
#include "zcrx.h"
78

89
union io_query_data {
910
struct io_uring_query_opcode opcodes;
11+
struct io_uring_query_zcrx zcrx;
1012
};
1113

1214
#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)
2729
return sizeof(*e);
2830
}
2931

32+
static ssize_t io_query_zcrx(union io_query_data *data)
33+
{
34+
struct io_uring_query_zcrx *e = &data->zcrx;
35+
36+
e->register_flags = ZCRX_REG_IMPORT;
37+
e->area_flags = IORING_ZCRX_AREA_DMABUF;
38+
e->nr_ctrl_opcodes = __ZCRX_CTRL_LAST;
39+
e->rq_hdr_size = sizeof(struct io_uring);
40+
e->rq_hdr_alignment = L1_CACHE_BYTES;
41+
e->__resv1 = 0;
42+
e->__resv2 = 0;
43+
return sizeof(*e);
44+
}
45+
3046
static int io_handle_query_entry(struct io_ring_ctx *ctx,
3147
union io_query_data *data, void __user *uhdr,
3248
u64 *next_entry)
@@ -55,6 +71,9 @@ static int io_handle_query_entry(struct io_ring_ctx *ctx,
5571
case IO_URING_QUERY_OPCODES:
5672
ret = io_query_ops(data);
5773
break;
74+
case IO_URING_QUERY_ZCRX:
75+
ret = io_query_zcrx(data);
76+
break;
5877
}
5978

6079
if (ret >= 0) {

0 commit comments

Comments
 (0)