[PATCH v2 2/2] io_uring: Add cqring_offset flags
Chris Packham
chris.packham at alliedtelesis.co.nz
Mon Jun 15 10:01:26 UTC 2020
Add support for displaying the recently added flags member of struct
io_cqring_offsets.
* configure.ac: detect io_cqring_offsets.flags
* io_uring.c: update to print io_cqring_offsets.flags
* tests/io_uring_setup.c: add test for same
* types/io_uring.h: update with definition from linux
* xlat/uring_cqring_flags.in: define IO_CQRING flags
---
configure.ac | 3 ++-
io_uring.c | 9 +++++----
tests/io_uring_setup.c | 31 +++++++++++++++++++++++++++----
types/io_uring.h | 4 +++-
xlat/uring_cqring_flags.in | 1 +
5 files changed, 38 insertions(+), 10 deletions(-)
create mode 100644 xlat/uring_cqring_flags.in
diff --git a/configure.ac b/configure.ac
index d0fd51ff..61777d39 100644
--- a/configure.ac
+++ b/configure.ac
@@ -483,7 +483,8 @@ AC_CHECK_HEADERS([linux/io_uring.h], [
AC_CHECK_MEMBERS(m4_normalize([
struct io_uring_params.features,
struct io_uring_params.wq_fd,
- struct io_uring_params.resv
+ struct io_uring_params.resv,
+ struct io_cqring_offsets.flags
]),,, [#include <linux/io_uring.h>])
])
diff --git a/io_uring.c b/io_uring.c
index 625c113c..c6a2fe0d 100644
--- a/io_uring.c
+++ b/io_uring.c
@@ -17,6 +17,7 @@
#include "xlat/uring_setup_flags.h"
#include "xlat/uring_enter_flags.h"
#include "xlat/uring_register_opcodes.h"
+#include "xlat/uring_cqring_flags.h"
SYS_FUNC(io_uring_setup)
{
@@ -71,10 +72,10 @@ SYS_FUNC(io_uring_setup)
PRINT_FIELD_U(", ", params.cq_off, ring_entries);
PRINT_FIELD_U(", ", params.cq_off, overflow);
PRINT_FIELD_U(", ", params.cq_off, cqes);
- if (!IS_ARRAY_ZERO(params.cq_off.resv)) {
- PRINT_FIELD_ARRAY(", ", params.cq_off, resv, tcp,
- print_xint64_array_member);
- }
+ PRINT_FIELD_FLAGS(", ", params.cq_off, flags,
+ uring_cqring_flags, "IORING_CQ_???");
+ PRINT_FIELD_X(", ", params.cq_off, resv1);
+ PRINT_FIELD_X(", ", params.cq_off, resv2);
tprints("}");
}
tprints("}");
diff --git a/tests/io_uring_setup.c b/tests/io_uring_setup.c
index 317b0d7a..808659ce 100644
--- a/tests/io_uring_setup.c
+++ b/tests/io_uring_setup.c
@@ -27,6 +27,7 @@
# include "xlat.h"
# include "xlat/uring_setup_features.h"
+# include "xlat/uring_cqring_flags.h"
# ifdef HAVE_STRUCT_IO_URING_PARAMS_FEATURES
# ifdef HAVE_STRUCT_IO_URING_PARAMS_WQ_FD
@@ -144,20 +145,42 @@ main(void)
params->sq_off.resv2);
printf("}, cq_off={head=%u, tail=%u, ring_mask=%u"
- ", ring_entries=%u, overflow=%u, cqes=%u",
+ ", ring_entries=%u, overflow=%u, cqes=%u flags=",
params->cq_off.head,
params->cq_off.tail,
params->cq_off.ring_mask,
params->cq_off.ring_entries,
params->cq_off.overflow,
params->cq_off.cqes);
- if (params->cq_off.resv[0] || params->cq_off.resv[1]) {
- printf(", resv=[%#llx, %#llx]",
+#ifdef HAVE_STRUCT_IO_CQRING_OFFSETS_FLAGS
+ printflags(uring_cqring_flags,
+ params->cq_off.flags,
+ "IORING_CQ_???");
+ if (params->cq_off.resv1) {
+ printf(", resv1=%#lx",
+ (unsigned long)
+ params->cq_off.resv1);
+ }
+ if (params->cq_off.resv2) {
+ printf(", resv2=%#llx",
(unsigned long long)
- params->cq_off.resv[0],
+ params->cq_off.resv2);
+ }
+#else
+ printflags(uring_cqring_flags,
+ params->cq_off.resv[0] >> 32,
+ "IORING_CQ_???");
+ if (params->cq_off.resv[0] & 0xffffffff) {
+ printf(", resv1=%#lx",
+ (unsigned long)
+ (params->cq_off.resv[0] & 0xffffffff));
+ }
+ if (params->cq_off.resv[1]) {
+ printf(", resv2=%#llx",
(unsigned long long)
params->cq_off.resv[1]);
}
+#endif
printf("}}) = %ld<anon_inode:[io_uring]>\n", rc);
}
diff --git a/types/io_uring.h b/types/io_uring.h
index 76f432c3..09f2fcef 100644
--- a/types/io_uring.h
+++ b/types/io_uring.h
@@ -31,7 +31,9 @@ typedef struct {
uint32_t ring_entries;
uint32_t overflow;
uint32_t cqes;
- uint64_t resv[2];
+ uint32_t flags;
+ uint32_t resv1;
+ uint64_t resv2;
} struct_io_cqring_offsets;
typedef struct {
diff --git a/xlat/uring_cqring_flags.in b/xlat/uring_cqring_flags.in
new file mode 100644
index 00000000..c81fbc20
--- /dev/null
+++ b/xlat/uring_cqring_flags.in
@@ -0,0 +1 @@
+IORING_CQ_EVENTFD_DISABLED 1U
--
2.27.0
More information about the Strace-devel
mailing list