AgeCommit message (Collapse)Author
2020-03-04test/orc: soft fail if filename isn't givenfd-selectJens Axboe
Otherwise the test suite complains. Signed-off-by: Jens Axboe <>
2020-03-04test/accept: add SOCK_SPECIFIC_FD test caseJens Axboe
Signed-off-by: Jens Axboe <>
2020-03-04Add sample open-read-close chainJens Axboe
Signed-off-by: Jens Axboe <>
2020-03-02test/send_recvmsg: cleanup on abortJens Axboe
If we don't have PROVIDE_BUFFERS, then ensure we free the ring, and (more importantly) up the mutex so we don't hang. Signed-off-by: Jens Axboe <>
2020-03-02test/splice: don't use memfdJens Axboe
The previous include is not enough, some older distros don't have the memfd_create() in libc. Just get rid of it and open a regular file instead. Signed-off-by: Jens Axboe <>
2020-03-02test/splice: include <linux/memfd.h>Jens Axboe
Signed-off-by: Jens Axboe <>
2020-03-02__io_uring_get_cqe: fix spurious -EAGAINJens Axboe
A previous patch always cleared the number to wait for once we'd done on io_uring_enter(), but we need to be sure that we've actually waited for the right amount before doing so. Check this by matching the return value with what we asked to submit - if it matches, we know we can safely clear 'wait_nr'. We also need to ensure that the original wait_nr is retained for the peek test. Fixes: 8a031500a304 ("__io_uring_get_cqe: eliminate unnecessary io_uring_enter() syscalls") Signed-off-by: Jens Axboe <>
2020-03-02__io_uring_get_cqe: don't subtract negative error from 'submit'Jens Axboe
Only subtract if we know it's >= 0. Signed-off-by: Jens Axboe <>
2020-03-02__io_uring_get_cqe: eliminate unnecessary io_uring_enter() syscallsXiaoguang Wang
When user applis programming mode, like sumbit one sqe and wait its completion event, __io_uring_get_cqe() will result in many unnecessary syscalls, see below test program: int main(int argc, char *argv[]) { struct io_uring ring; int fd, ret; struct io_uring_sqe *sqe; struct io_uring_cqe *cqe; struct iovec iov; off_t offset, filesize = 0; void *buf; if (argc < 2) { printf("%s: file\n", argv[0]); return 1; } ret = io_uring_queue_init(4, &ring, 0); if (ret < 0) { fprintf(stderr, "queue_init: %s\n", strerror(-ret)); return 1; } fd = open(argv[1], O_RDONLY | O_DIRECT); if (fd < 0) { perror("open"); return 1; } if (posix_memalign(&buf, 4096, 4096)) return 1; iov.iov_base = buf; iov.iov_len = 4096; offset = 0; do { sqe = io_uring_get_sqe(&ring); if (!sqe) { printf("here\n"); break; } io_uring_prep_readv(sqe, fd, &iov, 1, offset); ret = io_uring_submit(&ring); if (ret < 0) { fprintf(stderr, "io_uring_submit: %s\n", strerror(-ret)); return 1; } ret = io_uring_wait_cqe(&ring, &cqe); if (ret < 0) { fprintf(stderr, "io_uring_wait_cqe: %s\n", strerror(-ret)); return 1; } if (cqe->res <= 0) { if (cqe->res < 0) { fprintf(stderr, "got eror: %d\n", cqe->res); ret = 1; } io_uring_cqe_seen(&ring, cqe); break; } offset += cqe->res; filesize += cqe->res; io_uring_cqe_seen(&ring, cqe); } while (1); printf("filesize: %ld\n", filesize); close(fd); io_uring_queue_exit(&ring); return 0; } dd if=/dev/zero of=testfile bs=4096 count=16 ./test testfile and use bpftrace to trace io_uring_enter syscalls, in original codes, [lege@localhost ~]$ sudo bpftrace -e "tracepoint:syscalls:sys_enter_io_uring_enter {@c[tid] = count();}" Attaching 1 probe... @c[11184]: 49 Above test issues 49 syscalls, it's counterintuitive. After looking into the codes, it's because __io_uring_get_cqe issue one more syscall, indded when __io_uring_get_cqe issues the first syscall, one cqe should already be ready, we don't need to wait again. To fix this issue, after the first syscall, set wait_nr to be zero, with tihs patch, bpftrace shows the number of io_uring_enter syscall is 33. Signed-off-by: Xiaoguang Wang <> Signed-off-by: Jens Axboe <>
2020-02-29test/across-fork: have child wait for write finishJens Axboe
If we don't wait for the writes to finish, then the child exit could cause those writes to get canceled. Signed-off-by: Jens Axboe <>
2020-02-29test/send_recvmsg: ensure that we get -ENOBUFS for no buffersJens Axboe
Signed-off-by: Jens Axboe <>
2020-02-28test/send_recvmsg: add missing socket closeJens Axboe
This is especially important as we're now running two tests, and we don't want to leave one lingering and interfering. Signed-off-by: Jens Axboe <>
2020-02-28test/read-write: ensure SQPOLL for non-root just warnsJens Axboe
Don't fail the test. Signed-off-by: Jens Axboe <>
2020-02-28io_uring_prep_splice: fix 32-bit compat off_in truncationJens Axboe
Signed-off-by: Jens Axboe <>
2020-02-27test/send_recvmsg: add support for BUF_SELECTJens Axboe
Signed-off-by: Jens Axboe <>
2020-02-27Fix 32-bit warning for io_uring_prep_splice()Jens Axboe
../src/include/liburing.h: In function 'io_uring_prep_splice': ../src/include/liburing.h:200:50: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 200 | io_uring_prep_rw(IORING_OP_SPLICE, sqe, fd_out, (void *)off_in, Do the usual 32-bit cast trick. Fixes: 4f4eff4ca75f ("splice: add splice(2) helpers") Signed-off-by: Jens Axboe <>
2020-02-26Merge branch 'patch-1' of Axboe
* 'patch-1' of Needs an line break
2020-02-26Needs an line breakYoSTEALTH
2020-02-26test/poll-link: don't error out on connect failureJens Axboe
Just ignore the failure, it seems to trigger spuriously (like 1 in a 100 runs). Signed-off-by: Jens Axboe <>
2020-02-25Make it clear we're now on the 0.6 baseJens Axboe
This branch is what will turn into 0.6 eventually. Signed-off-by: Jens Axboe <>
2020-02-25test/read-write: fix non-root failureJens Axboe
Signed-off-by: Jens Axboe <>
2020-02-25test/link: fix typoJens Axboe
Signed-off-by: Jens Axboe <>
2020-02-25test/read-write: add test case for selectable buffersJens Axboe
Signed-off-by: Jens Axboe <>
2020-02-25Add IORING_OP_PROVIDE_BUFFERS and helperJens Axboe
Signed-off-by: Jens Axboe <>
2020-02-25test/sq-poll-kthread: include grace period before thread checkJens Axboe
Files can be put async, which means that it may very well be that the thread is alive the instant after io_uring_queue_exit() has returned. Add a 1 second grace period before checking, hopefully that's enough to remove false positives from this test. Signed-off-by: Jens Axboe <>
2020-02-24configure: sync struct open_how with kernel APIJens Axboe
This got changed and I missed it, now corrected... Signed-off-by: Jens Axboe <>
2020-02-24Reinstate io_uring_unregister_eventfd()Jens Axboe
When the probe registration was added, this got inadvertently deleted. Oops... Fixes: ec0ce0168742 ("Add io_uring_register_probe()") Fixes: Signed-off-by: Jens Axboe <>
2020-02-24test/splice: fix-up test case on kernels not supporting spliceJens Axboe
Signed-off-by: Jens Axboe <>
2020-02-24test/splice: add basic splice testsPavel Begunkov
Signed-off-by: Pavel Begunkov <> Minor edits/fixes Signed-off-by: Jens Axboe <>
2020-02-24splice: add splice(2) helpersPavel Begunkov
Add splice helpers and update io_uring.h Signed-off-by: Pavel Begunkov <> Signed-off-by: Jens Axboe <>
2020-02-23test/accept-link: update for FAST_POLLJens Axboe
We can actually cancel more easily with fast poll, as we don't have to return -EALREADY if a thread is running the work. Signed-off-by: Jens Axboe <>
2020-02-23Sync io_uring.h with 5.7-preJens Axboe
Signed-off-by: Jens Axboe <>
2020-02-21test: add sq-poll-kthread test caseliburing-0.4Stefano Garzarella
sq-poll-kthread tests if the 'io_uring-sq' kthread is stopped when the userspace process ended with or without closing the io_uring fd. Signed-off-by: Stefano Garzarella <> Signed-off-by: Jens Axboe <>
2020-02-20configure: fix mis-generation of compat.h for no __kernel_rwf_tJens Axboe
Signed-off-by: Jens Axboe <>
2020-02-20Merge branch 'dev' of Axboe
* 'dev' of liburing.h: add const type qualifier for io_uring_prep_write
2020-02-20man/io_uring_setup.2: fix 'sq_thread_idle' descriptionStefano Garzarella
In the kernel we are using msecs_to_jiffies() to convert the 'sq_thread_idle' parameter, provided by the user, in jiffies. So, the value is interpreted in milliseconds and not microseconds. Fixes: 59bb09c553eb ("man: add io_uring_setup.2 man page") Signed-off-by: Stefano Garzarella <> Signed-off-by: Jens Axboe <>
2020-02-20liburing.h: add const type qualifierCarter Li
for io_uring_prep_write Signed-off-by: Carter Li <>
2020-02-19Merge branch 'dev' of Axboe
* 'dev' of man/io_uring_enter.2: correct IORING_OP_STATX
2020-02-19man/io_uring_enter.2: correct IORING_OP_STATXCarter Li
Signed-off-by: Carter Li <>
2020-02-14Merge branch 'pu/test-suite' of Axboe
* 'pu/test-suite' of test: Initialize the data struct to set stop member to 0 test: Distinguish failure messages for accept-link test: Expect fail values from io_uring calls to be -errno instead of -1 test: Handle NULL sqe and cqe in tests test: Unify queue init failed error message test: Cleanup file artifacts on early exits test: Skip tests where the kernel lacks support Add src/include/liburing/compat.h to .gitignore
2020-02-14test: Initialize the data struct to set stop member to 0Guillem Jover
The send_thread() will do an early return if the stop member is true, which can happen in case we do not initialize the memory. Otherwise we will then get a failure with -EALREADY instead of the expected -ECANCELED. Signed-off-by: Guillem Jover <>
2020-02-14test: Distinguish failure messages for accept-linkGuillem Jover
We are testing two modes, one with accept, the other with accept and connect, and having the same error message makes it harder to see what went wrong where. Signed-off-by: Guillem Jover <>
2020-02-14test: Expect fail values from io_uring calls to be -errno instead of -1Guillem Jover
On error these functions return -errno instead of -1, otherwise we will not catch these and the tests will segfault. Signed-off-by: Guillem Jover <>
2020-02-14test: Handle NULL sqe and cqe in testsGuillem Jover
We need to check the return values from io_uring_queue_init() and recv_prep() or we will be passing a NULL sqe to io_uring_get_sqe(), or a NULL cge to io_uring_wait_cqe(). Signed-off-by: Guillem Jover <>
2020-02-14test: Unify queue init failed error messageGuillem Jover
Signed-off-by: Guillem Jover <>
2020-02-14test: Cleanup file artifacts on early exitsGuillem Jover
We should either unlink(2) the files after the first open in case we do not need them anymore, or when doing an early exit(2) to skip a test or from an error. Signed-off-by: Guillem Jover <>
2020-02-14test: Skip tests where the kernel lacks supportGuillem Jover
Signed-off-by: Guillem Jover <>
2020-02-14Add src/include/liburing/compat.h to .gitignoreGuillem Jover
Signed-off-by: Guillem Jover <>
2020-02-13test/poll-cancel-ton: reap events after submitJens Axboe
If the polls complete, then we can have events immediately. Ensure we nowait reap to prevent overflows. Signed-off-by: Jens Axboe <>
2020-02-12man/io_uring_register.2: add note of ring quiesce for file/buffers registrationJens Axboe
Signed-off-by: Jens Axboe <>