diff options
author | Eugene Syromyatnikov <evgsyr@gmail.com> | 2021-09-20 04:54:16 +0200 |
---|---|---|
committer | Eugene Syromyatnikov <evgsyr@gmail.com> | 2021-10-12 00:35:30 +0200 |
commit | 9958390ace65f6d51687db4cb1c9385243fff289 (patch) | |
tree | 06580a25625cdf114522de41b91a578c8cef6543 | |
parent | 647aef386bb586122de232a68eb653fc9d5198b5 (diff) | |
download | strace-9958390ace65f6d51687db4cb1c9385243fff289.tar.gz |
io_uring: implement IORING_REGISTER_IOWQ_MAX_WORKERS op decoding
Introduced by Linux commit v5.15-rc1~83^2~22.
* src/xlat/uring_iowq_acct.in: New file.
* src/io_uring.c: Include "xlat/uring_iowq_acct.h".
(print_io_uring_iowq_acct): New function.
(SYS_FUNC(io_uring_register)) <case IORING_REGISTER_IOWQ_MAX_WORKERS>:
Decode, call print_io_uring_iowq_acct.
* src/xlat/uring_register_opcodes.in (IORING_REGISTER_IOWQ_MAX_WORKERS):
New constant.
* tests/io_uring_register.c: Update expected output, add
IORING_REGISTER_IOWQ_MAX_WORKERS checks.
-rw-r--r-- | src/io_uring.c | 19 | ||||
-rw-r--r-- | src/xlat/uring_iowq_acct.in | 3 | ||||
-rw-r--r-- | src/xlat/uring_register_opcodes.in | 1 | ||||
-rw-r--r-- | tests/io_uring_register.c | 55 |
4 files changed, 76 insertions, 2 deletions
diff --git a/src/io_uring.c b/src/io_uring.c index 39f91d5f0..796e374bc 100644 --- a/src/io_uring.c +++ b/src/io_uring.c @@ -12,6 +12,7 @@ #include "xlat/uring_enter_flags.h" #include "xlat/uring_files_update_fds.h" +#include "xlat/uring_iowq_acct.h" #include "xlat/uring_op_flags.h" #include "xlat/uring_ops.h" #include "xlat/uring_setup_features.h" @@ -471,6 +472,19 @@ print_io_uring_update_rsrc(struct tcb *tcp, const kernel_ulong_t addr, tprint_struct_end(); } +static int +print_io_uring_iowq_acct(struct tcb *tcp, const kernel_ulong_t addr, + const unsigned int nargs) +{ + uint32_t val; + bool ret = print_array_ex(tcp, addr, nargs, &val, sizeof(val), + tfetch_mem, print_uint_array_member, NULL, + PAF_PRINT_INDICES | XLAT_STYLE_FMT_U, + uring_iowq_acct, "IO_WQ_???"); + + return ret ? 0 : RVAL_DECODED; +} + SYS_FUNC(io_uring_register) { const int fd = tcp->u_arg[0]; @@ -522,6 +536,11 @@ SYS_FUNC(io_uring_register) case IORING_REGISTER_IOWQ_AFF: print_affinitylist(tcp, arg, nargs); break; + case IORING_REGISTER_IOWQ_MAX_WORKERS: + rc = print_io_uring_iowq_acct(tcp, arg, nargs); + if (entering(tcp) && !rc) + tprint_value_changed(); + break; case IORING_UNREGISTER_BUFFERS: case IORING_UNREGISTER_FILES: case IORING_UNREGISTER_EVENTFD: diff --git a/src/xlat/uring_iowq_acct.in b/src/xlat/uring_iowq_acct.in new file mode 100644 index 000000000..136057835 --- /dev/null +++ b/src/xlat/uring_iowq_acct.in @@ -0,0 +1,3 @@ +#value_indexed +IO_WQ_BOUND 0 +IO_WQ_UNBOUND 1 diff --git a/src/xlat/uring_register_opcodes.in b/src/xlat/uring_register_opcodes.in index daa932dcd..966d8cb37 100644 --- a/src/xlat/uring_register_opcodes.in +++ b/src/xlat/uring_register_opcodes.in @@ -19,3 +19,4 @@ IORING_REGISTER_BUFFERS2 IORING_REGISTER_BUFFERS_UPDATE IORING_REGISTER_IOWQ_AFF IORING_UNREGISTER_IOWQ_AFF +IORING_REGISTER_IOWQ_MAX_WORKERS diff --git a/tests/io_uring_register.c b/tests/io_uring_register.c index 392804f31..f329c8095 100644 --- a/tests/io_uring_register.c +++ b/tests/io_uring_register.c @@ -165,7 +165,7 @@ main(void) /* Invalid op */ - static const unsigned int invalid_ops[] = { 0xbadc0dedU, 19 }; + static const unsigned int invalid_ops[] = { 0xbadc0dedU, 20 }; for (size_t i = 0; i < ARRAY_SIZE(invalid_ops); i++) { sys_io_uring_register(fd_null, invalid_ops[i], path_null, @@ -455,7 +455,7 @@ main(void) "register_op=", ARG_STR(IORING_UNREGISTER_IOWQ_AFF), true }, { ARG_STR(IORING_RESTRICTION_REGISTER_OP), true, - "register_op=", 19, " /* IORING_REGISTER_??? */", false }, + "register_op=", 20, " /* IORING_REGISTER_??? */", false }, { ARG_STR(IORING_RESTRICTION_REGISTER_OP), true, "register_op=", 255, " /* IORING_REGISTER_??? */", false }, { ARG_STR(IORING_RESTRICTION_SQE_OP), true, @@ -910,6 +910,57 @@ main(void) "], %zu) = %s\n", fd_null, path_null, sizeof(aff), errstr); + + /* IORING_REGISTER_IOWQ_MAX_WORKERS */ + unsigned int maxw[] = { 0, 1, 0xbedfaced }; + const unsigned int *arg_maxw = tail_memdup(maxw, sizeof(maxw)); + const unsigned int *arg_maxw_end = arg_maxw + ARRAY_SIZE(maxw); + + sys_io_uring_register(fd_null, 19, NULL, 0xfacefeed); + printf("io_uring_register(%u<%s>, " + XLAT_KNOWN(0x13, "IORING_REGISTER_IOWQ_MAX_WORKERS") + ", NULL, 4207869677) = %s\n", + fd_null, path_null, errstr); + + sys_io_uring_register(fd_null, 19, arg_maxw_end, 0); + printf("io_uring_register(%u<%s>, " + XLAT_KNOWN(0x13, "IORING_REGISTER_IOWQ_MAX_WORKERS") + ", [], 0) = %s\n", + fd_null, path_null, errstr); + + sys_io_uring_register(fd_null, 19, arg_maxw_end, 1); + printf("io_uring_register(%u<%s>, " + XLAT_KNOWN(0x13, "IORING_REGISTER_IOWQ_MAX_WORKERS") + ", %p, 1) = %s\n", + fd_null, path_null, arg_maxw_end, errstr); + + sys_io_uring_register(fd_null, 19, arg_maxw_end - 1, 2); + printf("io_uring_register(%u<%s>, " + XLAT_KNOWN(0x13, "IORING_REGISTER_IOWQ_MAX_WORKERS") ", [[" + XLAT_KNOWN(0, "IO_WQ_BOUND") "] = 3202329837, ... /* %p */]" + ", 2) = %s\n", + fd_null, path_null, arg_maxw_end, errstr); + + sys_io_uring_register(fd_null, 19, arg_maxw, 3); + printf("io_uring_register(%u<%s>, " + XLAT_KNOWN(0x13, "IORING_REGISTER_IOWQ_MAX_WORKERS") ", " + "[[" XLAT_KNOWN(0, "IO_WQ_BOUND") "] = 0, [" + XLAT_KNOWN(1, "IO_WQ_UNBOUND") "] = 1, [" + XLAT_UNKNOWN(2, "IO_WQ_???") "] = 3202329837] => " +#if RETVAL_INJECTED + "[[" XLAT_KNOWN(0, "IO_WQ_BOUND") "] = 0, [" + XLAT_KNOWN(1, "IO_WQ_UNBOUND") "] = 1, [" + XLAT_UNKNOWN(2, "IO_WQ_???") "] = 3202329837]" +#else + "%p" +#endif + ", 3) = %s\n", + fd_null, path_null, +#if !RETVAL_INJECTED + arg_maxw, +#endif + errstr); + puts("+++ exited with 0 +++"); return 0; } |