[RFC PATCH] io_uring: Handle io_cqring_offsets.flags
Dmitry V. Levin
ldv at altlinux.org
Fri Jun 12 13:00:41 UTC 2020
Hi,
On Fri, Jun 12, 2020 at 02:48:41PM +1200, Chris Packham wrote:
> The flags field was added in Linux v5.7-rc4-11-g0d9b5b3af134. Which
> trips up the static_assert in io_uring.c. Update
> struct_io_cqring_offsets with the new fields and adjust io_uring.c
> accordingly.
>
> Signed-off-by: Chris Packham <chris.packham at alliedtelesis.co.nz>
> ---
> This is my attempt top fix an issue I reported at https://github.com/strace/strace/issues/138
>
> Obviously this is lacking tests. I had a look at tests/io_uring_setup.c but got
> confused by HAVE_STRUCT_IO_URING_PARAMS_FEATURES and what the impications were
> for handling old/new kernels so I figured I'd send this as RFC and see what
> suggestions people had.
>
> io_uring.c | 25 ++++++++++++-------------
> types/io_uring.h | 4 +++-
> 2 files changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/io_uring.c b/io_uring.c
> index cd183457..1acf7cfa 100644
> --- a/io_uring.c
> +++ b/io_uring.c
> @@ -19,17 +19,17 @@
> #include "xlat/uring_register_opcodes.h"
>
> #ifdef HAVE_STRUCT_IO_CQRING_OFFSETS
> -# ifdef HAVE_STRUCT_IO_CQRING_OFFSETS_RESV
> -static_assert(offsetof(struct_io_cqring_offsets, resv)
> - >= offsetof(struct io_cqring_offsets, resv),
> - "struct io_cqring_offsets.resv offset mismatch"
> +# ifdef HAVE_STRUCT_IO_CQRING_OFFSETS_RESV2
> +static_assert(offsetof(struct_io_cqring_offsets, resv2)
> + >= offsetof(struct io_cqring_offsets, resv2),
> + "struct io_cqring_offsets.resv2 offset mismatch"
> ", please update the decoder");
> -static_assert(sizeof_field(struct_io_cqring_offsets, resv)
> - <= sizeof_field(struct io_cqring_offsets, resv),
> - "struct io_cqring_offsets.resv size mismatch"
> +static_assert(sizeof_field(struct_io_cqring_offsets, resv2)
> + <= sizeof_field(struct io_cqring_offsets, resv2),
> + "struct io_cqring_offsets.resv2 size mismatch"
> ", please update the decoder");
> -# else /* !HAVE_STRUCT_IO_CQRING_OFFSETS_RESV */
> -static_assert(0, "struct io_cqring_offsets.resv is missing"
> +# else /* !HAVE_STRUCT_IO_CQRING_OFFSETS_RESV2 */
> +static_assert(0, "struct io_cqring_offsets.resv2 is missing"
> ", please update the decoder");
> # endif
> #endif /* HAVE_STRUCT_IO_CQRING_OFFSETS */
This would break build with kernel headers that do not contain commit
0d9b5b3af134cddfdc1dd31d41946a0ad389bbf2.
I think these checks are no longer needed, given that generated
types/check-io_uring.c already checks this.
> @@ -103,10 +103,9 @@ 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_U(", ", params.cq_off, flags);
flags should rather be printed using PRINT_FIELD_FLAGS.
> + PRINT_FIELD_U(", ", params.cq_off, resv1);
> + PRINT_FIELD_U(", ", params.cq_off, resv2);
Reserved fields should rather be printed using PRINT_FIELD_X.
--
ldv
More information about the Strace-devel
mailing list