summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2019-08-28Make io_uring_peek_cqe() return -EAGAIN for no CQEsJens Axboe
Currently we return 0 if someone calls io_uring_peek_cqe(), but we really should be returning 0 only if we managed to find a completion entry. Return -EAGAIN to notify the caller that no entries are there. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-08-28liburing: specifying --prefix to configure script was ineffective, fix.Kevin Vigor
The configure script used the default value of the prefix variable (/usr) to determine the includedir etc. *before* parsing the command line to determine if the user specified a prefix. This made configure --prefix ineffective. Fix. Tested with configure --help, configure --prefix, configure --prefix --includedir Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-08-20liburing/barrier.h: Add prefix to arm barriersJulia Suvorova
Rename the newly added arm barriers and READ/WRITE_ONCE to avoid using popular names. Signed-off-by: Julia Suvorova <jusual@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-08-19liburing/barrier.h: Add prefix io_uring to barriersJulia Suvorova
The names of the barriers conflict with the namespaces of other projects when trying to directly include liburing.h. Avoid using popular global names. Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Julia Suvorova <jusual@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-08-08Add arm64 memory barriers supportJackie Liu
making liburing on arm64 platform failed. let's support it. root@Kylin:/# cat /etc/os-release PRETTY_NAME="Debian GNU/Linux buster/sid" root@Kylin:/# gcc -v gcc version 8.2.0 (Debian 8.2.0-20) root@Kylin:~/liburing# make make[1]: Entering directory '/root/liburing/src' cc -g -fomit-frame-pointer -O2 -Wall -Iinclude/ -c -o setup.ol setup.c In file included from include/liburing.h:14, from setup.c:10: include/liburing.h: In function 'io_uring_cq_advance': include/liburing/barrier.h:73:2: warning: implicit declaration of function 'smp_mb'; did you mean 'smp_wmb'? [-Wimplicit-function-declaration] smp_mb(); \ ^~~~~~ include/liburing.h:111:3: note: in expansion of macro 'smp_store_release' smp_store_release(cq->khead, *cq->khead + nr); ^~~~~~~~~~~~~~~~~ Signed-off-by: Jackie Liu <liuyun01@kylinos.cn> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-08-05Add basic READMEJens Axboe
Mostly for the purposes of github Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-08-03spec: fix <liburing/*.h> permissionsStefan Hajnoczi
There are two issues with the <liburing/*.h> headers: 1. They are installed with 0755 permissions. 2. The empty /usr/include/liburing/ directory is left behind by rpm -e. Fix this by specifying the directory (not just globbing the files inside it) and letting rpm use the default permissions on these files. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-08-03spec: add URL tagStefan Hajnoczi
rpmlint complains that there is no URL tag pointing to the software's website/documentation. Since liburing does not have a landing page, point to the cgit page where all information can be found. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-08-03spec: use Fedora "LGPLv2+" license identifierStefan Hajnoczi
rpmlint complains that "LGPL" is not a valid License tag. The License tag for "GNU Lesser General Public License v2 (or 2.1) or later" is "LGPLv2+" according to: https://fedoraproject.org/wiki/Licensing:Main Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-08-03COPYING: update to latest LGPL v2.1 textStefan Hajnoczi
rpmlint spotted that the LGPL v2.1 license file is outdated so I've replaced it with the latest one from https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. The Free Software Foundation address is outdated in COPYING and the file still mentions LGPL v2 where the latest text mentions v2.1: This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 2.1 of the License, or (at your option) any later version. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-07-24src/Makefile: keep private headers in <liburing/*.h>Stefan Hajnoczi
It is not possible to install barrier.h and compat.h into the top-level /usr/include directly since they are likely to conflict with other software. io_uring.h could be confused with the system's kernel header file. Put liburing headers into <liburing/*.h> so there is no chance of conflicts or confusion. Existing applications continue to build successfully since the location of <liburing.h> is unchanged. In-tree examples and tests require modification because src/liburing.h is moved to src/include/liburing.h. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-07-24src/Makefile: honor the caller's includedir and libdirStefan Hajnoczi
The top-level makefile passes in includedir and libdir so we should not override them. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-07-24spec: invoke ./configure with argumentsStefan Hajnoczi
Commit fd26c1a2f0eb ("configure: move directory options to ./configure") moved --prefix=PREFIX and other directory options to ./configure. Invoke ./configure with these options instead of passing them to the makefile. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-07-24pkgconfig: add missing config-host.mak dependencyStefan Hajnoczi
Rebuild the .pc file when config-host.mak changes since @prefix@, @libdir@, etc could have changed. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-07-16Don't take ownership of %{_mandir}/man2 directoryHrvoje Zeba
Yum doesn't like packages taking ownership of directories provided by other packages. Signed-off-by: Hrvoje Zeba <zeba.hrvoje@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-07-15man: add IOSQE_IO_DRAIN and IOSQE_IO_LINKJens Axboe
Add descriptions of these SQE flags. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-07-10Use __typeof() instead of typeof()Hrvoje Zeba
typeof() is not available on all compilers. __typeof() is a safer bet. Signed-off-by: Hrvoje Zeba <zeba.hrvoje@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-07-09Add regression test cases for kthread stuckJackie Liu
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-07-08Make runtests.sh output test to dmesgJens Axboe
Can be useful to figure out which test crashed. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-07-08Optimize i386 memory barriersBart Van Assche
Use identical memory barrier implementations on 32 and 64 bit Intel CPUs. In the past the Linux kernel supported 32 bit CPUs that violate the x86 ordering standard. Since io_uring is not supported by these older kernels, do not support these older CPUs in liburing. See also Linux kernel commit 5927145efd5d ("x86/cpu: Remove the CONFIG_X86_PPRO_FENCE=y quirk") # v4.16. Cc: Roman Penyaev <rpenyaev@suse.de> Suggested-by: Roman Penyaev <rpenyaev@suse.de> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-07-08Change __x86_64 into __x86_64__Bart Van Assche
This patch improves consistency with the Linux kernel source code. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-07-08Fix the 32-bit buildBart Van Assche
Fix the warnings reported when building liburing as follows: make CFLAGS=-m32 Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-07-08Makefiles: Support specifying CFLAGS on the command lineBart Van Assche
This patch makes the liburing build work as expected for e.g. the following command: make CFLAGS=-m32 and avoids that the build fails as follows for the above command: make[1]: Entering directory 'liburing/test' cc -m32 -o poll poll.c -luring /usr/bin/ld: cannot find -luring collect2: error: ld returned 1 exit status Makefile:18: recipe for target 'poll' failed make[1]: *** [poll] Error 1 make[1]: Leaving directory 'software/liburing/test' Makefile:12: recipe for target 'all' failed make: *** [all] Error 2 Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-07-02Fix the use of memory barriersBart Van Assche
Introduce the smp_load_acquire() and smp_store_release() macros. Fix synchronization in io_uring_cq_advance() and __io_uring_get_cqe(). Remove a superfluous local variable, if-test and write barrier from __io_uring_submit(). Remove a superfluous barrier from test/io_uring_enter.c. Cc: Stefan Hajnoczi <stefanha@redhat.com> Cc: Roman Penyaev <rpenyaev@suse.de> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-07-02__io_uring_get_cqe(): Use io_uring_for_each_cqe()Bart Van Assche
Use io_uring_for_each_cqe() inside __io_uring_get_cqe() such that it becomes possible to test the io_uring_for_each_cqe() implementation from inside the liburing project. Cc: Stefan Hajnoczi <stefanha@redhat.com> Cc: Roman Penyaev <rpenyaev@suse.de> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-06-17src/queue: cleanup sq_ring_needs_enter()Jens Axboe
Don't check for IORING_SQ_NEED_WAKEUP twice, put it inside sq_ring_needs_enter(). Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-06-17Add support for eventfd registrationJens Axboe
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-06-17Make io_uring registration arguments constJens Axboe
We don't modify them, make that clear. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-06-13example/io_uring-test.c: Fix iovecs incrementStephen Bates
This example misses an increment though the iovecs array. This causes the same buffer to be filled from the block device every time. It would be good to fix this since it is one of the first examples a new-comer to io_uring is exposed too. Signed-off-by: Stephen Bates <sbates@raithlin.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-06-06Add io_uring_submit_and_wait()Jens Axboe
Works just like io_uring_submit(), but also allows retrieving events (or waiting/polling for them) in the same call. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-06-04Add basic helpers for file/buffer registrationJens Axboe
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-06-04test/ring-leak: use static array for io_uring_register()Jens Axboe
Don't leak the memory. We never need to reference it from the test app once the io_uring_register() call is done. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-06-04test/io_uring_register: don't test buffer size if too largeJens Axboe
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-06-03Do not assume p->{cq,sq}_off.head is 0Kornilios Kourtis
Ring memory is released by umapping {cq,sq}->khead, which assumes that p->{cq,sq}_off.head will always be 0. Add another field to for the mmaped region and use that instead of ->khead when umapping. Signed-off-by: Kornilios Kourtis <kkourt@kkourt.io> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-29liburing: export io_uring_queue_mmap symbolAustin Seipp
io_uring_queue_mmap wasn't exported from the ld map file, meaning the linker gave it private, static linkage in the resulting shared object, as opposed to global linkage. This results in the symbol seemingly missing at link-time, despite the existence of the symbol in the library itself. Signed-off-by: Austin Seipp <aseipp@pobox.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-27test/fsync: use io_uring_sqe_set_flags()Jens Axboe
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-27liburing: introduce io_uring_for_each_cqe() and io_uring_cq_advance()Roman Penyaev
io_uring_cqe_seen() contains write memory barrier (at least for !x86), so calling it can be very expensive for a big number of cqes. Would be better to have a loop over all available cqes and only then advance the cq ring once, e.g.: struct io_uring_cqe *cqe; unsigned nr, head; nr = 0; io_uring_for_each_cqe(&ring, head, cqe) { /* handle cqe */ if (++nr == max) break; } io_uring_cq_advance(&ring, nr); Signed-off-by: Roman Penyaev <rpenyaev@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-27liburing: introduce io_uring_cqe_set_flags() helperRoman Penyaev
Signed-off-by: Roman Penyaev <rpenyaev@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-27queue: always fill in sq->array on io_uring_submit()Roman Penyaev
io_uring_submit() is a last commit point when a caller has to be sure that all prepared sqes eventually lands to the kernel. If SQ thread is running it is quite possible that khead != ktail, thus charging of sq->array is skipped, which leads to IO hang. Nasty hang is well reproduced when submitter and completion harverster are different threads. Signed-off-by: Roman Penyaev <rpenyaev@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-27liburing,queue,setup: handle IORING_SQ_NEED_WAKEUP for io_uring_submit()Roman Penyaev
Enter kernel only if SQ thread is off or wakeup is needed. Signed-off-by: Roman Penyaev <rpenyaev@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-27setup: return -errno explicitly from io_uring_queue_init()Roman Penyaev
Signed-off-by: Roman Penyaev <rpenyaev@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-26Add pkgconfig to rpm specHrvoje Zeba
pkgconfig file is installed but not referenced in the rpm's spec file so rpmbuild fails. Signed-off-by: Hrvoje Zeba <zeba.hrvoje@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-25configure: move directory options to ./configureStefan Hajnoczi
libdir is hardcoded to ${prefix}/lib in Makefile. Fedora x86_64 uses /usr/lib64 and this means libaries will be installed in the wrong place. This patch moves prefix, includedir, libdir, and mandir into ./configure for easier customization. To build and install on Fedora x86_64: # ./configure --libdir=/usr/lib64 # make && make install Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-25pkgconfig: install a liburing.pc fileStefan Hajnoczi
pkg-config (https://pkgconfig.freedesktop.org/) makes it easier to build applications that have library dependencies. Libraries ship .pc files containing the compiler and linker flags needed to build successfully. This saves applications from hardcoding these details into their build scripts, especially when these details can change between operating systems or distributions. To build a liburing application: gcc $(pkg-config --cflags --libs liburing) -o myapp myapp.c Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-24test/send_recvmsg: code cleanups and error handlingJens Axboe
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-23Add send/recvmsg test caseJens Axboe
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-23io_uring.h: add send/recvmsg partsJens Axboe
This syncs with io_uring-next, which has support for doing recvmsg and sendmsg through io_uring. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-22examples/io_uring-cp: fix a NULL pointer dereferencezhangliguang
In case malloc fails, the fix returns NULL to avoid NULL pointer dereference. Signed-off-by: zhangliguang <zhangliguang@linux.alibaba.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-21clean examples when make cleanWeiping Zhang
Signed-off-by: Weiping Zhang <zhangweiping@didiglobal.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-21io_uring_submit: fix head/tail wrap issueJens Axboe
Use proper unsigned math to figure out how many entries we have. If we have head and tail on either side of UINT_MAX, then we currently don't submit anything as: while (head < tail) { is never true. Reported-by: Weiping Zhang <zhangweiping@didiglobal.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>