strace/SOURCES/0114-io_uring-Add-io_cqring_offset-flags.patch
2021-10-08 16:58:09 +00:00

384 lines
14 KiB
Diff

From c51b292b237214ccfcae5a84085f8d0a7e85c8ba Mon Sep 17 00:00:00 2001
From: Chris Packham <chris.packham@alliedtelesis.co.nz>
Date: Mon, 15 Jun 2020 22:01:26 +1200
Subject: [PATCH 114/115] io_uring: Add io_cqring_offset flags
Add support for displaying struct io_cqring_offsets.flags introduced
by Linux kernel commits v5.8-rc1~190^2~22 and v5.8-rc1~190^2~21.
* types/io_uring.h (struct_io_cqring_offsets): Replace resv array
with flags, resv1, and resv2 fields.
* xlat/uring_cqring_flags.in: New file.
* configure.ac (AC_CHECK_MEMBERS): Check struct io_cqring_offsets.flags.
* io_uring.c: Include "xlat/uring_cqring_flags.h".
(SYS_FUNC(io_uring_setup)): Replace printing of the resv array
of struct io_cqring_offsets with flags, resv1, and resv2 fields.
* tests/io_uring_setup.c: Check it.
Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
Resolves: https://github.com/strace/strace/issues/138
---
configure.ac | 1 +
io_uring.c | 11 +++++++----
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
Index: strace-5.7/configure.ac
===================================================================
--- strace-5.7.orig/configure.ac 2020-11-09 04:39:07.197892960 +0100
+++ strace-5.7/configure.ac 2020-11-09 04:39:14.943826575 +0100
@@ -481,6 +481,7 @@
AC_CHECK_HEADERS([linux/io_uring.h], [
AC_CHECK_MEMBERS(m4_normalize([
+ struct io_cqring_offsets.flags,
struct io_uring_params.features,
struct io_uring_params.wq_fd,
struct io_uring_params.resv
Index: strace-5.7/io_uring.c
===================================================================
--- strace-5.7.orig/io_uring.c 2020-11-09 04:39:07.197892960 +0100
+++ strace-5.7/io_uring.c 2020-11-09 04:39:14.943826575 +0100
@@ -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"
#ifdef HAVE_STRUCT_IO_URING_PARAMS
# ifdef HAVE_STRUCT_IO_URING_PARAMS_RESV
@@ -88,10 +89,12 @@
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_???");
+ if (params.cq_off.resv1)
+ PRINT_FIELD_X(", ", params.cq_off, resv1);
+ if (params.cq_off.resv2)
+ PRINT_FIELD_X(", ", params.cq_off, resv2);
tprints("}");
}
tprints("}");
Index: strace-5.7/tests/io_uring_setup.c
===================================================================
--- strace-5.7.orig/tests/io_uring_setup.c 2020-11-09 04:39:07.197892960 +0100
+++ strace-5.7/tests/io_uring_setup.c 2020-11-09 04:39:14.943826575 +0100
@@ -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,40 @@
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=%#x", 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
+ union {
+ struct {
+ uint32_t flags;
+ uint32_t resv1;
+ } s;
+ uint64_t v;
+ } u = { .v = params->cq_off.resv[0] };
+ printflags(uring_cqring_flags, u.s.flags,
+ "IORING_CQ_???");
+ if (u.s.resv1)
+ printf(", resv1=%#x", u.s.resv1);
+ 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);
}
Index: strace-5.7/types/io_uring.h
===================================================================
--- strace-5.7.orig/types/io_uring.h 2020-11-09 04:39:07.198892952 +0100
+++ strace-5.7/types/io_uring.h 2020-11-09 04:39:14.944826567 +0100
@@ -31,7 +31,9 @@
uint32_t ring_entries;
uint32_t overflow;
uint32_t cqes;
- uint64_t resv[2];
+ /** Added by v5.8-rc1~190^2~22 */ uint32_t flags;
+ /** Added by v5.8-rc1~190^2~22 */ uint32_t resv1;
+ /** Added by v5.8-rc1~190^2~22 */ uint64_t resv2;
} struct_io_cqring_offsets;
typedef struct {
Index: strace-5.7/xlat/uring_cqring_flags.in
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/xlat/uring_cqring_flags.in 2020-11-09 04:39:14.944826567 +0100
@@ -0,0 +1 @@
+IORING_CQ_EVENTFD_DISABLED 1U
Index: strace-5.7/Makefile.in
===================================================================
--- strace-5.7.orig/Makefile.in 2020-11-09 04:39:07.201892926 +0100
+++ strace-5.7/Makefile.in 2020-11-09 04:42:54.519945367 +0100
@@ -1506,10 +1506,10 @@
xlat/uffd_register_mode_flags.in xlat/uffd_zeropage_flags.in \
xlat/umount_flags.in xlat/unix_diag_attrs.in \
xlat/unix_diag_show.in xlat/unshare_flags.in \
- xlat/uring_enter_flags.in xlat/uring_op_flags.in \
- xlat/uring_ops.in xlat/uring_register_opcodes.in \
- xlat/uring_setup_features.in xlat/uring_setup_flags.in \
- xlat/usagewho.in xlat/v4l2_buf_flags.in \
+ xlat/uring_cqring_flags.in xlat/uring_enter_flags.in \
+ xlat/uring_op_flags.in xlat/uring_ops.in \
+ xlat/uring_register_opcodes.in xlat/uring_setup_features.in \
+ xlat/uring_setup_flags.in xlat/usagewho.in xlat/v4l2_buf_flags.in \
xlat/v4l2_buf_flags_masks.in xlat/v4l2_buf_flags_ts_src.in \
xlat/v4l2_buf_flags_ts_type.in xlat/v4l2_buf_types.in \
xlat/v4l2_capture_modes.in xlat/v4l2_colorspaces.in \
@@ -1755,10 +1755,10 @@
xlat/uffd_register_mode_flags.h xlat/uffd_zeropage_flags.h \
xlat/umount_flags.h xlat/unix_diag_attrs.h \
xlat/unix_diag_show.h xlat/unshare_flags.h \
- xlat/uring_enter_flags.h xlat/uring_op_flags.h \
- xlat/uring_ops.h xlat/uring_register_opcodes.h \
- xlat/uring_setup_features.h xlat/uring_setup_flags.h \
- xlat/usagewho.h xlat/v4l2_buf_flags.h \
+ xlat/uring_cqring_flags.h xlat/uring_enter_flags.h \
+ xlat/uring_op_flags.h xlat/uring_ops.h \
+ xlat/uring_register_opcodes.h xlat/uring_setup_features.h \
+ xlat/uring_setup_flags.h xlat/usagewho.h xlat/v4l2_buf_flags.h \
xlat/v4l2_buf_flags_masks.h xlat/v4l2_buf_flags_ts_src.h \
xlat/v4l2_buf_flags_ts_type.h xlat/v4l2_buf_types.h \
xlat/v4l2_capture_modes.h xlat/v4l2_colorspaces.h \
@@ -9974,6 +9974,8 @@
$(AM_V_GEN)$(top_srcdir)/xlat/gen.sh $< $@
$(top_srcdir)/xlat/unshare_flags.h: $(top_srcdir)/xlat/unshare_flags.in $(top_srcdir)/xlat/gen.sh
$(AM_V_GEN)$(top_srcdir)/xlat/gen.sh $< $@
+$(top_srcdir)/xlat/uring_cqring_flags.h: $(top_srcdir)/xlat/uring_cqring_flags.in $(top_srcdir)/xlat/gen.sh
+ $(AM_V_GEN)$(top_srcdir)/xlat/gen.sh $< $@
$(top_srcdir)/xlat/uring_enter_flags.h: $(top_srcdir)/xlat/uring_enter_flags.in $(top_srcdir)/xlat/gen.sh
$(AM_V_GEN)$(top_srcdir)/xlat/gen.sh $< $@
$(top_srcdir)/xlat/uring_op_flags.h: $(top_srcdir)/xlat/uring_op_flags.in $(top_srcdir)/xlat/gen.sh
Index: strace-5.7/configure
===================================================================
--- strace-5.7.orig/configure 2020-11-09 04:39:07.205892892 +0100
+++ strace-5.7/configure 2020-11-09 05:07:10.675485410 +0100
@@ -12580,7 +12580,17 @@
#define HAVE_LINUX_IO_URING_H 1
_ACEOF
- ac_fn_c_check_member "$LINENO" "struct io_uring_params" "features" "ac_cv_member_struct_io_uring_params_features" "#include <linux/io_uring.h>
+ ac_fn_c_check_member "$LINENO" "struct io_cqring_offsets" "flags" "ac_cv_member_struct_io_cqring_offsets_flags" "#include <linux/io_uring.h>
+"
+if test "x$ac_cv_member_struct_io_cqring_offsets_flags" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_IO_CQRING_OFFSETS_FLAGS 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_member "$LINENO" "struct io_uring_params" "features" "ac_cv_member_struct_io_uring_params_features" "#include <linux/io_uring.h>
"
if test "x$ac_cv_member_struct_io_uring_params_features" = xyes; then :
Index: strace-5.7/tests-m32/io_uring_setup.c
===================================================================
--- strace-5.7.orig/tests-m32/io_uring_setup.c 2020-11-09 04:39:07.206892883 +0100
+++ strace-5.7/tests-m32/io_uring_setup.c 2020-11-09 04:39:14.951826507 +0100
@@ -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,40 @@
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=%#x", 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
+ union {
+ struct {
+ uint32_t flags;
+ uint32_t resv1;
+ } s;
+ uint64_t v;
+ } u = { .v = params->cq_off.resv[0] };
+ printflags(uring_cqring_flags, u.s.flags,
+ "IORING_CQ_???");
+ if (u.s.resv1)
+ printf(", resv1=%#x", u.s.resv1);
+ 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);
}
Index: strace-5.7/tests-mx32/io_uring_setup.c
===================================================================
--- strace-5.7.orig/tests-mx32/io_uring_setup.c 2020-11-09 04:39:07.206892883 +0100
+++ strace-5.7/tests-mx32/io_uring_setup.c 2020-11-09 04:39:14.951826507 +0100
@@ -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,40 @@
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=%#x", 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
+ union {
+ struct {
+ uint32_t flags;
+ uint32_t resv1;
+ } s;
+ uint64_t v;
+ } u = { .v = params->cq_off.resv[0] };
+ printflags(uring_cqring_flags, u.s.flags,
+ "IORING_CQ_???");
+ if (u.s.resv1)
+ printf(", resv1=%#x", u.s.resv1);
+ 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);
}
Index: strace-5.7/xlat/uring_cqring_flags.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-5.7/xlat/uring_cqring_flags.h 2020-11-09 05:07:27.046345327 +0100
@@ -0,0 +1,48 @@
+/* Generated by ./xlat/gen.sh from ./xlat/uring_cqring_flags.in; do not edit. */
+
+#include "gcc_compat.h"
+#include "static_assert.h"
+
+#if defined(IORING_CQ_EVENTFD_DISABLED) || (defined(HAVE_DECL_IORING_CQ_EVENTFD_DISABLED) && HAVE_DECL_IORING_CQ_EVENTFD_DISABLED)
+DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE
+static_assert((IORING_CQ_EVENTFD_DISABLED) == (1U), "IORING_CQ_EVENTFD_DISABLED != 1U");
+DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE
+#else
+# define IORING_CQ_EVENTFD_DISABLED 1U
+#endif
+
+#ifndef XLAT_MACROS_ONLY
+
+# ifdef IN_MPERS
+
+# error static const struct xlat uring_cqring_flags in mpers mode
+
+# else
+
+static const struct xlat_data uring_cqring_flags_xdata[] = {
+ XLAT(IORING_CQ_EVENTFD_DISABLED),
+ #define XLAT_VAL_0 ((unsigned) (IORING_CQ_EVENTFD_DISABLED))
+ #define XLAT_STR_0 STRINGIFY(IORING_CQ_EVENTFD_DISABLED)
+};
+static
+const struct xlat uring_cqring_flags[1] = { {
+ .data = uring_cqring_flags_xdata,
+ .size = ARRAY_SIZE(uring_cqring_flags_xdata),
+ .type = XT_NORMAL,
+ .flags_mask = 0
+# ifdef XLAT_VAL_0
+ | XLAT_VAL_0
+# endif
+ ,
+ .flags_strsz = 0
+# ifdef XLAT_STR_0
+ + sizeof(XLAT_STR_0)
+# endif
+ ,
+} };
+
+# undef XLAT_STR_0
+# undef XLAT_VAL_0
+# endif /* !IN_MPERS */
+
+#endif /* !XLAT_MACROS_ONLY */