Added Refrence for Linux Asynchronous IO APIs in LTP
cover Added Refrence for Linux Asynchronous IO APIs in LTP
Enabled Linux Asynchronous IO(AIO) family of APIs in LTP AIO API: io_uring_setup(), io_uring_register(), io_uring_enter()
Refrences for Linux AIO-
https://lwn.net/Articles/776703/
https://kernel.dk/io_uring.pdf
https://www.mankier.com/2/io_uring_setup
https://www.mankier.com/2/io_uring_register
https://www.mankier.com/2/io_uring_enter
---
Vikas Kumar (1):
Added Refrence for Linux Asynchronous IO APIs in LTP
configure.ac | 3 + include/lapi/io_uring.h | 180 ++++++++++++++++++ testcases/kernel/syscalls/io_uring/.gitignore | 1 + testcases/kernel/syscalls/io_uring/Makefile | 25 +++ .../kernel/syscalls/io_uring/io_uring01.c | 85 +++++++++ 5 files changed, 294 insertions(+) create mode 100644 include/lapi/io_uring.h create mode 100644 testcases/kernel/syscalls/io_uring/.gitignore create mode 100644 testcases/kernel/syscalls/io_uring/Makefile create mode 100644 testcases/kernel/syscalls/io_uring/io_uring01.c
Signature · 1 line
2.17.1
PATCH 1/1 Added Refrence for Linux Asynchronous IO APIs in LTP
Added Linux Asynchronous IO(AIO) family of APIs in LTP AIO API: io_uring_setup(), io_uring_register(), io_uring_enter()
Refrences for Linux AIO-
https://lwn.net/Articles/776703/
https://kernel.dk/io_uring.pdf
https://www.mankier.com/2/io_uring_setup
https://www.mankier.com/2/io_uring_register
https://www.mankier.com/2/io_uring_enter
---
--- configure.ac | 3 + include/lapi/io_uring.h | 180 ++++++++++++++++++ testcases/kernel/syscalls/io_uring/.gitignore | 1 + testcases/kernel/syscalls/io_uring/Makefile | 25 +++ .../kernel/syscalls/io_uring/io_uring01.c | 85 +++++++++ 5 files changed, 294 insertions(+) create mode 100644 include/lapi/io_uring.h create mode 100644 testcases/kernel/syscalls/io_uring/.gitignore create mode 100644 testcases/kernel/syscalls/io_uring/Makefile create mode 100644 testcases/kernel/syscalls/io_uring/io_uring01.c
configure.ac +3 -0
@@ -88,6 +88,9 @@ AC_CHECK_FUNCS([ \ getdents \ getdents64 \ io_pgetevents \ + io_uring_setup \ + io_uring_register \ + io_uring_enter \ kcmp \ mkdirat \ mknodat \
include/lapi/io_uring.h new file +180 -0
180 lines not on this page · raw message
testcases/kernel/syscalls/io_uring/.gitignore new file +1 -0
@@ -0,0 +1 @@ +/io_submit01
testcases/kernel/syscalls/io_uring/Makefile new file +25 -0
@@ -0,0 +1,25 @@ +# +# Copyright (c) International Business Machines Corp., 2001 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +# the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk + +LDLIBS += $(AIO_LIBS) + +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/io_uring/io_uring01.c new file +85 -0
85 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 1/1 Added Refrence for Linux Asynchronous IO APIs in LTP
Hi Vikas,
Maybe first line of the commit message should be simple:
"syscalls: Add io_uring tests".
Quoted 4 lines
Added Linux Asynchronous IO(AIO) family of APIs in LTP AIO API:
io_uring_setup(),io_uring_register(),io_uring_enter()Refrences for Linux AIO-
FYI: you can add version to your patch set by -vN (this patch should have been sent with -v2).
I need to look into io_uring, so this time it's just about small errors and formatting.
The main problem I see is that the test actually does not test much. What was your intention to test? Name of the test and directory suggests you want to test all 3 syscalls, but you actually test just one flag for io_uring_register(). It'd be good add a more tests (or we can merge your commit and add more tests ourselves).
Maybe take some examples from doc? https://kernel.dk/io_uring.pdf mentions at least https://git.kernel.dk/cgit/fio/tree/t/io_uring.c.
Quoted 5 lines
https://lwn.net/Articles/776703/
https://kernel.dk/io_uring.pdf
https://www.mankier.com/2/io_uring_setup
https://www.mankier.com/2/io_uring_register
https://www.mankier.com/2/io_uring_enter
I'd remove these docs links.
Quoted 39 lines
Signed-off-by Vikas Kumar <[email protected]>---
--- configure.ac | 3 + include/lapi/io_uring.h | 180 ++++++++++++++++++ testcases/kernel/syscalls/io_uring/.gitignore | 1 + testcases/kernel/syscalls/io_uring/Makefile | 25 +++ .../kernel/syscalls/io_uring/io_uring01.c | 85 +++++++++ 5 files changed, 294 insertions(+) create mode 100644 include/lapi/io_uring.h create mode 100644 testcases/kernel/syscalls/io_uring/.gitignore create mode 100644 testcases/kernel/syscalls/io_uring/Makefile create mode 100644 testcases/kernel/syscalls/io_uring/io_uring01.cconfigure.ac +3
-0@@ -88,6 +88,9 @@ AC_CHECK_FUNCS([ \ getdents \ getdents64 \ io_pgetevents \ + io_uring_setup \ + io_uring_register \ + io_uring_enter \ kcmp \ mkdirat \ mknodat \include/lapi/io_uring.h new file +4
-0@@ -0,0 +1,180 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2020 ARM. All rights reserved. +* Author: Vikas Kumar <[email protected]>
include/lapi/io_uring.h line 14
Quoted 10 lines
include/lapi/io_uring.h new file +10
-0+*/ + +#ifndef IO_URING_H__ +#define IO_URING_H__ + +#include <unistd.h> +#include <fcntl.h> +#include <sys/syscall.h> +#include <sys/types.h> +#include <sys/uio.h>
You also need <stdlib.h> (for malloc(), compiler warns you if you compile the test).
include/lapi/io_uring.h line 21
Quoted 7 lines
include/lapi/io_uring.h new file +7
-0+ + +#include "config.h" +#include "lapi/syscalls.h" + + +
Sorry for formatting nit: here are unnecessary blank lines (although they are needed to make code readable, one is usually enough). Also blank lines before } (end of function) doesn't help readability. On the other hand you sometimes don't put space after comma in function arguments.
include/lapi/io_uring.h line 22
Quoted 1 line
include/lapi/io_uring.h new file +1
-0+#ifndef HAVE_IO_URING_SETUP || HAVE_IO_URING_REGISTER || HAVE_IO_URING_ENTER
This is wrong (if you compile it, you'll see it).
This would work
#if !(defined(HAVE_IO_URING_SETUP) || defined(HAVE_IO_URING_REGISTER) || defined(HAVE_IO_URING_ENTER))
but I guess checking existence of first definition would be enough:
#ifndef IOSQE_FIXED_FILE
Quoted 41 lines
include/lapi/io_uring.h new file +41
-0+ + +/* sqe->flags */ +#define IOSQE_FIXED_FILE (1U << 0)/* use fixed fileset */ +#define IOSQE_IO_DRAIN (1U << 1)/* issue after inflight IO */ +#define IOSQE_IO_LINK (1U << 2)/* links next sqe */ +#define IOSQE_IO_HARDLINK (1U << 3)/* like LINK, but stronger */ + +/* io_uring_setup() flags */ +#define IORING_SETUP_IOPOLL (1U << 0)/* io_context is polled */ +#define IORING_SETUP_SQPOLL (1U << 1)/* SQ poll thread */ +#define IORING_SETUP_SQ_AFF (1U << 2)/* sq_thread_cpu is valid */ +#define IORING_SETUP_CQSIZE (1U << 3)/* app defines CQ size */ + +/* sqe->fsync_flags */ +#define IORING_FSYNC_DATASYNC (1U << 0) + +/* sqe->timeout_flags */ +#define IORING_TIMEOUT_ABS (1U << 0) + +/* Magic offsets for the application to mmap the data it needs */ +#define IORING_OFF_SQ_RING 0ULL +#define IORING_OFF_CQ_RING 0x8000000ULL +#define IORING_OFF_SQES 0x10000000ULL + +/* sq_ring->flags */ +#define IORING_SQ_NEED_WAKEUP (1U << 0)/* needs io_uring_enter wakeup */ + +/* io_uring_enter(2) flags */ +#define IORING_ENTER_GETEVENTS (1U << 0) +#define IORING_ENTER_SQ_WAKEUP (1U << 1) + +/* io_uring_params->features flags */ +#define IORING_FEAT_SINGLE_MMAP (1U << 0) +#define IORING_FEAT_NODROP (1U << 1) +#define IORING_FEAT_SUBMIT_STABLE (1U << 2) + +/* io_uring_register(2) opcodes and arguments */ +#define IORING_REGISTER_BUFFERS 0 +#define IORING_UNREGISTER_BUFFERS 1 +#define IORING_REGISTER_FILES 2
include/lapi/io_uring.h line 73
Quoted 10 lines
include/lapi/io_uring.h new file +10
-0+#define IORING_UNREGISTER_FILES 3 +#define IORING_REGISTER_EVENTFD 4 +#define IORING_UNREGISTER_EVENTFD 5 +#define IORING_REGISTER_FILES_UPDATE 6 + +#endif + + + +#ifndef HAVE_IO_URING_SETUP || HAVE_IO_URING_REGISTER || HAVE_IO_URING_ENTER
I didn't get why you repeat the condition?
Quoted 127 lines
include/lapi/io_uring.h new file +107
-0+ +enum { +IORING_OP_NOP , +IORING_OP_READV , +IORING_OP_WRITEV , +IORING_OP_FSYNC , +IORING_OP_READ_FIXED , +IORING_OP_WRITE_FIXED , +IORING_OP_POLL_ADD , +IORING_OP_POLL_REMOVE , +IORING_OP_SYNC_FILE_RANGE , +IORING_OP_SENDMSG , +IORING_OP_RECVMSG , +IORING_OP_TIMEOUT , +IORING_OP_TIMEOUT_REMOVE , +IORING_OP_ACCEPT , +IORING_OP_ASYNC_CANCEL , +IORING_OP_LINK_TIMEOUT , +IORING_OP_CONNECT , + +/* this goes last, obviously */ +IORING_OP_LAST , +}; + +/* IO completion data structure (Completion Queue Entry) */ +struct io_uring_cqe { +uint64_t user_data;/* sqe->data submission passed back */ +int32_t res;/* result code for this event */ +uint32_t flags; +}; + +/* Filled with the offset for mmap(2) */ +struct io_sqring_offsets { +uint32_t head; +uint32_t tail; +uint32_t ring_mask; +uint32_t ring_entries; +uint32_t flags; +uint32_t dropped; +uint32_t array; +uint32_t resv1; +uint64_t resv2; +}; + +struct io_cqring_offsets { +uint32_t head; +uint32_t tail; +uint32_t ring_mask; +uint32_t ring_entries; +uint32_t overflow; +uint32_t cqes; +uint64_t resv[2 ]; +}; + +/* Passed in for io_uring_setup(2). Copied back with updated info on success */ +struct io_uring_params { +uint32_t sq_entries; +uint32_t cq_entries; +uint32_t flags; +uint32_t sq_thread_cpu; +uint32_t sq_thread_idle; +uint32_t features; +uint32_t resv[4 ]; +struct io_sqring_offsets sq_off; +struct io_cqring_offsets cq_off; +}; + + +struct io_uring_files_update { +uint32_t offset; +uint32_t resv; +uint64_t __attribute__((aligned (8 ))) fds; +}; + +#endif + + +#ifndef HAVE_IO_URING_REGISTER +int io_uring_register (int fd,unsigned int opcode,void *arg, +unsigned int nr_args) +{ +return tst_syscall (__NR_io_uring_register, fd, opcode, arg, nr_args); +} +#endif /* HAVE_IO_URING_REGISTER */ + + +#ifndef HAVE_IO_URING_SETUP +int io_uring_setup (unsigned int entries,struct io_uring_params *p) +{ +return tst_syscall (__NR_io_uring_setup, entries, p); +} +#endif /* HAVE_IO_URING_SETUP */ + +#ifndef HAVE_IO_URING_ENTER +int io_uring_enter (int fd,unsigned int to_submit,unsigned int min_complete, +unsigned int flags,sigset_t *sig) +{ +return tst_syscall (__NR_io_uring_enter, fd, to_submit, min_complete, + flags, sig, _NSIG /8 ); +} +#endif /* HAVE_IO_URING_ENTER */ + + + +#endif /* IO_URING_H__ */ + +testcases/kernel/syscalls/io_uring/.gitignore new file +1
-0@@ -0,0 +1 @@ +/io_submit01testcases/kernel/syscalls/io_uring/Makefile new file +7
-0@@ -0,0 +1,25 @@ +# +# Copyright (c) International Business Machines Corp., 2001 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version.
testcases/kernel/syscalls/io_uring/Makefile line 17
Quoted 10 lines
testcases/kernel/syscalls/io_uring/Makefile new file +10
-0+# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +# the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#
This verbose GPL text should be replaced by:
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2020 ARM Embedded Technologies Private Ltd. All rights reserved.
Quoted 30 lines
testcases/kernel/syscalls/io_uring/Makefile new file +8
-0+ +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk + +LDLIBS += $(AIO_LIBS) + +include $(top_srcdir)/include/mk/generic_leaf_target.mktestcases/kernel/syscalls/io_uring/io_uring01.c new file +16
-0@@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2020 ARM Embedded Technologies Private Ltd. All rights reserved. +* Author: Vikas Kumar <[email protected]> +* +* Use new Linux AIO API io_uring_*(). +*/ + +#include <errno.h> +#include <string.h> +#include <fcntl.h> + +#include "config.h" +#include "tst_test.h" + +#include "lapi/syscalls.h"
testcases/kernel/syscalls/io_uring/io_uring01.c line 26
Quoted 10 lines
testcases/kernel/syscalls/io_uring/io_uring01.c new file +10
-0+#include "lapi/io_uring.h" + + +#define DEPTH 1 + +struct io_uring_params param_iouring; +int fd, ret; +struct iovec iovecs; +void *iov_base_addr; +int iov_size =64 ;
iov_size is used just in setup(), should be moved there.
testcases/kernel/syscalls/io_uring/io_uring01.c line 29
Quoted 3 lines
testcases/kernel/syscalls/io_uring/io_uring01.c new file +3
-0+ +static struct tcase { + int test_count;
You don't use test_count at all. What do you wanted to have it for?
testcases/kernel/syscalls/io_uring/io_uring01.c line 32
Quoted 3 lines
testcases/kernel/syscalls/io_uring/io_uring01.c new file +3
-0+int test_no; +} tcases[] = { +/* TEST IO URING REGISTER BUFFERS*/
This commit is IMHO useless.
testcases/kernel/syscalls/io_uring/io_uring01.c line 34
Quoted 2 lines
testcases/kernel/syscalls/io_uring/io_uring01.c new file +2
-0+ {1, IORING_REGISTER_BUFFERS}, +};
Well, I've noted that this does not cover much.
Quoted 20 lines
testcases/kernel/syscalls/io_uring/io_uring01.c new file +20
-0+ +static void setup (void ) +{ + +memset (¶m_iouring,0 ,sizeof (param_iouring)); + + param_iouring.flags |=IORING_SETUP_IOPOLL ; + + fd =io_uring_setup (DEPTH , ¶m_iouring); +if (!fd) +tst_brk (TBROK |TERRNO ,"io_uring_setup() returned %d" , fd); + + iov_base_addr =malloc (sizeof (iov_size)); + + iovecs.iov_base = iov_base_addr; + iovecs.iov_len = iov_size; + +} + +static void cleanup (void )
testcases/kernel/syscalls/io_uring/io_uring01.c line 64
Quoted 10 lines
testcases/kernel/syscalls/io_uring/io_uring01.c new file +10
-0+{ +io_uring_register (fd,IORING_UNREGISTER_BUFFERS ,NULL ,DEPTH ); +memset (¶m_iouring,0 ,sizeof (param_iouring)); +free (iov_base_addr); +} + + +static void verify_io_submit (unsigned int n) +{ +struct tcase *t = &tcases[n];
You don't use t at all...
testcases/kernel/syscalls/io_uring/io_uring01.c line 67
Quoted 3 lines
testcases/kernel/syscalls/io_uring/io_uring01.c new file +3
-0+int ret; + + ret =io_uring_register (fd,IORING_REGISTER_BUFFERS , &iovecs,DEPTH );
you should use it like
testcases/kernel/syscalls/io_uring/io_uring01.c line 68
Quoted 1 line
testcases/kernel/syscalls/io_uring/io_uring01.c new file +1
-0+ ret =io_uring_register (fd, t->flag, &iovecs,DEPTH );
We usually use TEST() macro...
testcases/kernel/syscalls/io_uring/io_uring01.c line 74
Quoted 7 lines
testcases/kernel/syscalls/io_uring/io_uring01.c new file +7
-0+ +if (ret ==0 ) { +tst_res (TPASS ,"io_uring_register() return %d" ,ret); +return ; + } + +tst_res (TFAIL ,"io_uring_register() returned %d" ,ret);
... something like this:
TEST(io_uring_register(fd, tc->flag, &iovecs, DEPTH));
if (TST_RET == -1) {
tst_res(TFAIL | TTERRNO, "io_uring_register() returned %d", ret);
return;
}
tst_res(TPASS, "io_uring_register() return %d",ret);Kind regards,
Petr
PATCH 1/1 Added Refrence for Linux Asynchronous IO APIs in LTP
Hi Vikas,
I did most of formatting cleanup for you, you can use it as a base for v3:
https://github.com/pevik/ltp/tree/Vikas_Kumar/io_uring.v2.fixes
Kind regards,
Petr
PATCH 1/1 Added Refrence for Linux Asynchronous IO APIs in LTP
In reply to Vikas KumarHi!
Quoted 246 lines
Added Linux Asynchronous IO(AIO) family of APIs in LTP AIO API:
io_uring_setup(),io_uring_register(),io_uring_enter()Refrences for Linux AIO-
https://lwn.net/Articles/776703/
https://kernel.dk/io_uring.pdf
https://www.mankier.com/2/io_uring_setup
https://www.mankier.com/2/io_uring_register
https://www.mankier.com/2/io_uring_enterSigned-off-by Vikas Kumar <[email protected]>---
--- configure.ac | 3 + include/lapi/io_uring.h | 180 ++++++++++++++++++ testcases/kernel/syscalls/io_uring/.gitignore | 1 + testcases/kernel/syscalls/io_uring/Makefile | 25 +++ .../kernel/syscalls/io_uring/io_uring01.c | 85 +++++++++ 5 files changed, 294 insertions(+) create mode 100644 include/lapi/io_uring.h create mode 100644 testcases/kernel/syscalls/io_uring/.gitignore create mode 100644 testcases/kernel/syscalls/io_uring/Makefile create mode 100644 testcases/kernel/syscalls/io_uring/io_uring01.cconfigure.ac +3
-0@@ -88,6 +88,9 @@ AC_CHECK_FUNCS([ \ getdents \ getdents64 \ io_pgetevents \ + io_uring_setup \ + io_uring_register \ + io_uring_enter \ kcmp \ mkdirat \ mknodat \include/lapi/io_uring.h new file +180
-0@@ -0,0 +1,180 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2020 ARM. All rights reserved. +* Author: Vikas Kumar <[email protected]> +*/ + +#ifndef IO_URING_H__ +#define IO_URING_H__ + +#include <unistd.h> +#include <fcntl.h> +#include <sys/syscall.h> +#include <sys/types.h> +#include <sys/uio.h> + + +#include "config.h" +#include "lapi/syscalls.h" + + + +#ifndef HAVE_IO_URING_SETUP || HAVE_IO_URING_REGISTER || HAVE_IO_URING_ENTER + + +/* sqe->flags */ +#define IOSQE_FIXED_FILE (1U << 0) /* use fixed fileset */ +#define IOSQE_IO_DRAIN (1U << 1) /* issue after inflight IO */ +#define IOSQE_IO_LINK (1U << 2) /* links next sqe */ +#define IOSQE_IO_HARDLINK (1U << 3) /* like LINK, but stronger */ + +/* io_uring_setup() flags */ +#define IORING_SETUP_IOPOLL (1U << 0) /* io_context is polled */ +#define IORING_SETUP_SQPOLL (1U << 1) /* SQ poll thread */ +#define IORING_SETUP_SQ_AFF (1U << 2) /* sq_thread_cpu is valid */ +#define IORING_SETUP_CQSIZE (1U << 3) /* app defines CQ size */ + +/* sqe->fsync_flags */ +#define IORING_FSYNC_DATASYNC (1U << 0) + +/* sqe->timeout_flags */ +#define IORING_TIMEOUT_ABS (1U << 0) + +/* Magic offsets for the application to mmap the data it needs */ +#define IORING_OFF_SQ_RING 0ULL +#define IORING_OFF_CQ_RING 0x8000000ULL +#define IORING_OFF_SQES 0x10000000ULL + +/* sq_ring->flags */ +#define IORING_SQ_NEED_WAKEUP (1U << 0) /* needs io_uring_enter wakeup */ + +/* io_uring_enter(2) flags */ +#define IORING_ENTER_GETEVENTS (1U << 0) +#define IORING_ENTER_SQ_WAKEUP (1U << 1) + +/* io_uring_params->features flags */ +#define IORING_FEAT_SINGLE_MMAP (1U << 0) +#define IORING_FEAT_NODROP (1U << 1) +#define IORING_FEAT_SUBMIT_STABLE (1U << 2) + +/* io_uring_register(2) opcodes and arguments */ +#define IORING_REGISTER_BUFFERS 0 +#define IORING_UNREGISTER_BUFFERS 1 +#define IORING_REGISTER_FILES 2 +#define IORING_UNREGISTER_FILES 3 +#define IORING_REGISTER_EVENTFD 4 +#define IORING_UNREGISTER_EVENTFD 5 +#define IORING_REGISTER_FILES_UPDATE 6 + +#endif + + + +#ifndef HAVE_IO_URING_SETUP || HAVE_IO_URING_REGISTER || HAVE_IO_URING_ENTER + +enum { + IORING_OP_NOP, + IORING_OP_READV, + IORING_OP_WRITEV, + IORING_OP_FSYNC, + IORING_OP_READ_FIXED, + IORING_OP_WRITE_FIXED, + IORING_OP_POLL_ADD, + IORING_OP_POLL_REMOVE, + IORING_OP_SYNC_FILE_RANGE, + IORING_OP_SENDMSG, + IORING_OP_RECVMSG, + IORING_OP_TIMEOUT, + IORING_OP_TIMEOUT_REMOVE, + IORING_OP_ACCEPT, + IORING_OP_ASYNC_CANCEL, + IORING_OP_LINK_TIMEOUT, + IORING_OP_CONNECT, + + /* this goes last, obviously */ + IORING_OP_LAST, +}; + +/* IO completion data structure (Completion Queue Entry) */ +struct io_uring_cqe { + uint64_t user_data; /* sqe->data submission passed back */ + int32_t res; /* result code for this event */ + uint32_t flags; +}; + +/* Filled with the offset for mmap(2) */ +struct io_sqring_offsets { + uint32_t head; + uint32_t tail; + uint32_t ring_mask; + uint32_t ring_entries; + uint32_t flags; + uint32_t dropped; + uint32_t array; + uint32_t resv1; + uint64_t resv2; +}; + +struct io_cqring_offsets { + uint32_t head; + uint32_t tail; + uint32_t ring_mask; + uint32_t ring_entries; + uint32_t overflow; + uint32_t cqes; + uint64_t resv[2]; +}; + +/* Passed in for io_uring_setup(2). Copied back with updated info on success */ +struct io_uring_params { + uint32_t sq_entries; + uint32_t cq_entries; + uint32_t flags; + uint32_t sq_thread_cpu; + uint32_t sq_thread_idle; + uint32_t features; + uint32_t resv[4]; + struct io_sqring_offsets sq_off; + struct io_cqring_offsets cq_off; +}; + + +struct io_uring_files_update { + uint32_t offset; + uint32_t resv; + uint64_t __attribute__((aligned(8))) fds; +}; + +#endif + + +#ifndef HAVE_IO_URING_REGISTER +int io_uring_register(int fd, unsigned int opcode, void *arg, + unsigned int nr_args) +{ + return tst_syscall(__NR_io_uring_register, fd, opcode, arg, nr_args); +} +#endif /* HAVE_IO_URING_REGISTER */ + + +#ifndef HAVE_IO_URING_SETUP +int io_uring_setup(unsigned int entries, struct io_uring_params *p) +{ + return tst_syscall(__NR_io_uring_setup, entries, p); +} +#endif /* HAVE_IO_URING_SETUP */ + +#ifndef HAVE_IO_URING_ENTER +int io_uring_enter(int fd, unsigned int to_submit, unsigned int min_complete, + unsigned int flags, sigset_t *sig) +{ + return tst_syscall(__NR_io_uring_enter, fd, to_submit, min_complete, + flags, sig, _NSIG / 8); +} +#endif /* HAVE_IO_URING_ENTER */ + + + +#endif /* IO_URING_H__ */ + +testcases/kernel/syscalls/io_uring/.gitignore new file +1
-0@@ -0,0 +1 @@ +/io_submit01testcases/kernel/syscalls/io_uring/Makefile new file +7
-0@@ -0,0 +1,25 @@ +# +# Copyright (c) International Business Machines Corp., 2001 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version.
testcases/kernel/syscalls/io_uring/Makefile line 17
Quoted 10 lines
testcases/kernel/syscalls/io_uring/Makefile new file +10
-0+# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +# the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#
Use SPDX instead please.
testcases/kernel/syscalls/io_uring/Makefile line 23
Quoted 5 lines
testcases/kernel/syscalls/io_uring/Makefile new file +5
-0+top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk + +LDLIBS += $(AIO_LIBS)
I'm pretty sure the test does not need the AIO_LIBS
Quoted 31 lines
testcases/kernel/syscalls/io_uring/Makefile new file +1
-0+include $(top_srcdir)/include/mk/generic_leaf_target.mktestcases/kernel/syscalls/io_uring/io_uring01.c new file +24
-0@@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2020 ARM Embedded Technologies Private Ltd. All rights reserved. +* Author: Vikas Kumar <[email protected]> +* +* Use new Linux AIO API io_uring_*(). +*/ + +#include <errno.h> +#include <string.h> +#include <fcntl.h> + +#include "config.h" +#include "tst_test.h" + +#include "lapi/syscalls.h" +#include "lapi/io_uring.h" + + +#define DEPTH 1 + +struct io_uring_params param_iouring; +int fd, ret; +struct iovec iovecs;
testcases/kernel/syscalls/io_uring/io_uring01.c line 34
Quoted 10 lines
testcases/kernel/syscalls/io_uring/io_uring01.c new file +10
-0+void *iov_base_addr; +int iov_size =64 ; + +static struct tcase { +int test_count; +int test_no; +} tcases[] = { +/* TEST IO URING REGISTER BUFFERS*/ + {1 ,IORING_REGISTER_BUFFERS }, +};
It does not make much sense to create this structure if there is only one test.
testcases/kernel/syscalls/io_uring/io_uring01.c line 38
Quoted 3 lines
testcases/kernel/syscalls/io_uring/io_uring01.c new file +3
-0+static void setup (void ) +{ +
^
There are trailing whitespaces all around the place, you can use the checkpatch.pl packed with the Linux kernel to check for these before submitting.
testcases/kernel/syscalls/io_uring/io_uring01.c line 50
Quoted 12 lines
testcases/kernel/syscalls/io_uring/io_uring01.c new file +12
-0+memset (¶m_iouring,0 ,sizeof (param_iouring)); + + param_iouring.flags |=IORING_SETUP_IOPOLL ; + + fd =io_uring_setup (DEPTH , ¶m_iouring); +if (!fd) +tst_brk (TBROK |TERRNO ,"io_uring_setup() returned %d" , fd); + + iov_base_addr =malloc (sizeof (iov_size)); + + iovecs.iov_base = iov_base_addr; + iovecs.iov_len = iov_size;
This should really be a guarded buffer, you can even allocate whole iovec strcuture with guarded buffers see:
https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines#2231-guarded-buffers
testcases/kernel/syscalls/io_uring/io_uring01.c line 56
Quoted 5 lines
testcases/kernel/syscalls/io_uring/io_uring01.c new file +5
-0+} + +static void cleanup (void ) +{ +io_uring_register (fd,IORING_UNREGISTER_BUFFERS ,NULL ,DEPTH );
This should be in the main loop, otherwise the test will fail with -i 2 option.
testcases/kernel/syscalls/io_uring/io_uring01.c line 55
Quoted 1 line
testcases/kernel/syscalls/io_uring/io_uring01.c new file +1
-0+memset (¶m_iouring,0 ,sizeof (param_iouring));
This memset is useless, we are finished there is no point in clearing the structure.
Quoted 7 lines
testcases/kernel/syscalls/io_uring/io_uring01.c new file +7
-0+free (iov_base_addr); +} + + +static void verify_io_submit (unsigned int n) +{ +struct tcase *t = &tcases[n];
testcases/kernel/syscalls/io_uring/io_uring01.c line 74
Quoted 10 lines
testcases/kernel/syscalls/io_uring/io_uring01.c new file +10
-0+int ret; + + ret =io_uring_register (fd,IORING_REGISTER_BUFFERS , &iovecs,DEPTH ); + +if (ret ==0 ) { +tst_res (TPASS ,"io_uring_register() return %d" ,ret); +return ; + } + +tst_res (TFAIL ,"io_uring_register() returned %d" ,ret);
We should really write something here as well.
Quoted 13 lines
testcases/kernel/syscalls/io_uring/io_uring01.c new file +10
-0+} + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test = verify_io_submit, + .tcnt =ARRAY_SIZE (tcases), +}; + +Signature · 1 line
2.17.1
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 Added Refrence for Linux Asynchronous IO APIs in LTP
In reply to Vikas KumarHi Vikas,
we decided to take only header and configure.ac as these are valid parts and good preparation steps. So I removed the test itself and also updated header to reflect v5.6 changes.
I also dared to remove your Author: line (but kept copyright of course), as Jens Axboe and other kernel developers are the authors :).
Kind regards,
Petr
PATCH 1/1 Added Refrence for Linux Asynchronous IO APIs in LTP
Hi Petr,
Sure please go ahead with header and configure.ac changes. I will post next set of V3 Patch changes on top of it.
Regards,
Vkas
________________________________
From: Petr Vorel <[email protected]>
Sent: Tuesday, March 31, 2020 4:12 PM
To: Vikas Kumar <[email protected]>
Cc: [email protected] <[email protected]>; Anshuman Khandual <[email protected]>; [email protected] <[email protected]>
Subject: Re: [LTP] [PATCH 1/1] Added Refrence for Linux Asynchronous IO APIs in LTP
Hi Vikas,
we decided to take only header and configure.ac as these are valid parts and good preparation steps. So I removed the test itself and also updated header to reflect v5.6 changes.
I also dared to remove your Author: line (but kept copyright of course), as Jens Axboe and other kernel developers are the authors :).
Kind regards,
Petr
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200331/8371167a/attachment.htm>