summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
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-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-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-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-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-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-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-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-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-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>
2019-05-20Fix leak of fd in io_uring_queue_init() on failureJens Axboe
If the ring setup fails, close the fd before returning failure. Reported-by: Kornilios Kourtis <kkourt@kkourt.io> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-20fix harmless typo in sq_entries in io_uring_mmapWeiping Zhang
We really should use a ';' to terminate the line. This is just a cosmetic issue, no functional changes. Signed-off-by: Weiping Zhang <zhangweiping@didiglobal.com> Modified wording Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-20Add missing symbols to linker version mapHrvoje Zeba
Some of the symbols were missing from linker version script so they weren't exported in the dynamic library. Signed-off-by: Hrvoje Zeba <zeba.hrvoje@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-20syscall: add support of non-x86 architecturesDmitry V. Levin
Fortunately, all architectures except alpha have common numbers for new system calls nowadays, so support of non-alpha architectures is as simple as support of x86. Signed-off-by: Dmitry V. Levin <ldv@altlinux.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-20syscall: fix names of __NR_* macrosDmitry V. Levin
Rename __NR_sys_io_uring* to __NR_io_uring* to match kernel headers. The prefix traditionally used for macros describing syscall numbers is "__NR_", not "__NR_sys_". Signed-off-by: Dmitry V. Levin <ldv@altlinux.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-19Match const signatures in io_uring_prep_* to native functionsIan Gulliver
io_uring_prep_{readv,writev,read_fixed,write_fixed}() take non-const arguments that are const in the native functions that they mimic. Make those arguments const. Signed-off-by: Ian Gulliver <git@flamingcow.io>
2019-05-18Fix liburing.h memset() missing declarationIan Gulliver
liburing.h uses memset() but doesn't include string.h. If nothing else includes it, this causes compile errors. Add the include. Signed-off-by: Ian Gulliver <git@flamingcow.io>
2019-05-18io_uring.h: sync with kernelJens Axboe
Add sync_range_file opcode and related fields, and the io_uring_register(2) commands for eventfd registration. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-13Add link SQE supportJens Axboe
Just a basic test case that does various forms of linked nops, and a sample bare bones copy program using linked reads and writes. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-06liburing: add extern "C" to liburing.hKevin Vigor
Make header includable from C++ projects. Signed-off-by: Kevin Vigor <kvigor@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-06liburing: do not build static library with -fPICKevin Vigor
Static libraries are generally built without -fPIC for slight performance gain, make that the case for liburing. Signed-off-by: Kevin Vigor <kvigor@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-06liburing: improve 'make install'Kevin Vigor
'make install' did not install all the headers necessary to use the library; fix. Additionally allow specifying the install prefix, which was previously hardcoded to /usr. Signed-off-by: Kevin Vigor <kvigor@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-18Rename completion helpersJens Axboe
We have io_uring_get_sqe() on the submission side, yet the completion side is named _completion. Rename as follows: io_uring_get_completion() io_uring_peek_cqe() iO_uring_wait_completion() io_uring_wait_cqe() This better tells the user what the _get variant does by calling it _peek instead, and we move to using _cqe() as the postfix instead of _completion. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-17Add io_uring_cqe_seen()Jens Axboe
There's a failure case where an application gets a cqe entry, but the kernel can then overwrite it before the application is done reading it. This can happen since the io_uring_{get,wait}_completion() interface both returns a CQE pointer AND increments the ring index. If the kernel reuses this entry before the applications is done reading it, the contents may be corrupted. Remove the CQ head increment from the CQE retrieval, and put it into a separate helper, io_uring_cqe_seen(). The application must call this helper when it got a new CQE entry through one of the above calls, and it's now done reading it. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-11test/nop: add NOP test caseJens Axboe
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-10test/fsync: update for IOSQE_IO_DRAIN approachJens Axboe
I generalized the barrier flag to be applicable to all commands, so let's drop the fsync special flag. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-07Add io_uring_cqe_get_data()Zach Bjornson
Signed-off-by: Zach Bjornson <zbbjornson@gmail.com> Add uintptr_t cast to avoid 32-bit warnings. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-06Add barrier fsync test caseJens Axboe
Also changes the fsync prep helper to require passing in the actual flag, not just a boolean for fsync vs fdatasync. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-03-19Remove IOCQE_FLAG_CACHEHITJens Axboe
This cache hint has been removed from the io_uring series, as there's some hesitation to leak this information to userspace. Remove it from the header file and the man page. We can always re-introduce it later, if we get some variant of this included. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-03-13queue: ensure io_uring_submit() returns the system call valueJens Axboe
A previous fix that ensured we pass back the right error messed up the normal return, which is number of entries submitted. This makes the poll test cases fail. Fixes: 8260029608b9 ("queue: ensure io_uring_submit() returns the right error") Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-03-05queue: ensure io_uring_submit() returns the right errorJens Axboe
We weren't passing back -errno for the system call failure. This meant any error got turned into EPERM as far as the caller was concerned. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-02-28Add read/write fixed prep supportJens Axboe
Also unify the setup, all the read/write variants can use the same helper. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-02-15src/queue: kill bogus ktail_next == head checkJens Axboe
This really wants to be a "will we over-fill the ring?" kind of check, but the sqe_head/sqe_tail should not be that far apart. If they are, that's a bug elsewhere. So just kill the check. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-02-10Sync io_uring.h with the kernelJens Axboe
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-02-10src/queue: add comments on the read and write barriersJens Axboe
Signed-off-by: Jens Axboe <axboe@kernel.dk>