Blame SOURCES/0114-io_uring-Add-io_cqring_offset-flags.patch

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