Message ID | 20220915062715.233884-3-zhaogongyi@huawei.com |
---|---|
State | Changes Requested |
Headers | show |
Series | Optimize io_uring related testcases | expand |
Hi! > -static inline void io_uring_setup_supported_by_kernel(void) > -{ > - long ret; > - if ((tst_kvercmp(5, 1, 0)) < 0) { > - ret = syscall(__NR_io_uring_setup, NULL, 0); > - if (ret != -1) > - SAFE_CLOSE(ret); > - else if (errno == ENOSYS) > - tst_brk(TCONF, > - "Test not supported on kernel version < v5.1"); > - } > -} I guess I see the problem now, with the CONFIG_IO_URING not set this will fail to detect that io_uring() is not supported. So the easiest solution here would be: diff --git a/include/lapi/io_uring.h b/include/lapi/io_uring.h index 397324511..43d28f74a 100644 --- a/include/lapi/io_uring.h +++ b/include/lapi/io_uring.h @@ -297,14 +297,22 @@ static inline int io_uring_enter(int fd, unsigned int to_submit, static inline void io_uring_setup_supported_by_kernel(void) { long ret; + + ret = syscall(__NR_io_uring_setup, NULL, 0); + + if (ret != -1) { + SAFE_CLOSE(ret); + return; + } + if ((tst_kvercmp(5, 1, 0)) < 0) { - ret = syscall(__NR_io_uring_setup, NULL, 0); - if (ret != -1) - SAFE_CLOSE(ret); - else if (errno == ENOSYS) + if (errno == ENOSYS) tst_brk(TCONF, "Test not supported on kernel version < v5.1"); } + + if (errno == ENOSYS) + tst_brk(TCONF, "CONFIG_IO_URING not set?"); }
Hi! > diff --git a/include/lapi/io_uring.h b/include/lapi/io_uring.h > index 397324511..43d28f74a 100644 > --- a/include/lapi/io_uring.h > +++ b/include/lapi/io_uring.h > @@ -297,14 +297,22 @@ static inline int io_uring_enter(int fd, unsigned int to_submit, > static inline void io_uring_setup_supported_by_kernel(void) > { > long ret; > + > + ret = syscall(__NR_io_uring_setup, NULL, 0); > + > + if (ret != -1) { > + SAFE_CLOSE(ret); > + return; > + } > + > if ((tst_kvercmp(5, 1, 0)) < 0) { > - ret = syscall(__NR_io_uring_setup, NULL, 0); > - if (ret != -1) > - SAFE_CLOSE(ret); > - else if (errno == ENOSYS) > + if (errno == ENOSYS) > tst_brk(TCONF, > "Test not supported on kernel version < v5.1"); > } > + > + if (errno == ENOSYS) Based on your latest reply this should be EOPNOTSUPP. > + tst_brk(TCONF, "CONFIG_IO_URING not set?"); > } > > > -- > Cyril Hrubis > chrubis@suse.cz > > -- > Mailing list info: https://lists.linux.it/listinfo/ltp
diff --git a/include/lapi/io_uring.h b/include/lapi/io_uring.h index 397324511..8f1dfd64c 100644 --- a/include/lapi/io_uring.h +++ b/include/lapi/io_uring.h @@ -294,17 +294,4 @@ static inline int io_uring_enter(int fd, unsigned int to_submit, } #endif /* HAVE_IO_URING_ENTER */ -static inline void io_uring_setup_supported_by_kernel(void) -{ - long ret; - if ((tst_kvercmp(5, 1, 0)) < 0) { - ret = syscall(__NR_io_uring_setup, NULL, 0); - if (ret != -1) - SAFE_CLOSE(ret); - else if (errno == ENOSYS) - tst_brk(TCONF, - "Test not supported on kernel version < v5.1"); - } -} - #endif /* LAPI_IO_URING_H__ */ diff --git a/testcases/kernel/syscalls/io_uring/io_uring01.c b/testcases/kernel/syscalls/io_uring/io_uring01.c index cb1cabcb7..41aa05da0 100644 --- a/testcases/kernel/syscalls/io_uring/io_uring01.c +++ b/testcases/kernel/syscalls/io_uring/io_uring01.c @@ -252,7 +252,6 @@ static void run(unsigned int n) static void setup(void) { - io_uring_setup_supported_by_kernel(); tst_fill_file(TEST_FILE, 'a', 1024, 1); } diff --git a/testcases/kernel/syscalls/io_uring/io_uring02.c b/testcases/kernel/syscalls/io_uring/io_uring02.c index c7ea87ae5..a04e759f8 100644 --- a/testcases/kernel/syscalls/io_uring/io_uring02.c +++ b/testcases/kernel/syscalls/io_uring/io_uring02.c @@ -75,8 +75,6 @@ static void setup(void) if (ret >= (int)sizeof(addr.sun_path)) tst_brk(TBROK, "Tempdir path is too long"); - io_uring_setup_supported_by_kernel(); - sendsock = SAFE_SOCKET(AF_UNIX, SOCK_DGRAM, 0); recvsock = SAFE_SOCKET(AF_UNIX, SOCK_DGRAM, 0); SAFE_BIND(recvsock, (struct sockaddr *)&addr, sizeof(addr));
There is a kernel config CONFIG_IO_URING to control whether io_uring is supported, so checking of the kernel version seems redundant. Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com> --- include/lapi/io_uring.h | 13 ------------- testcases/kernel/syscalls/io_uring/io_uring01.c | 1 - testcases/kernel/syscalls/io_uring/io_uring02.c | 2 -- 3 files changed, 16 deletions(-) -- 2.17.1