summaryrefslogtreecommitdiff
path: root/examples
AgeCommit message (Collapse)Author
5 daysucontext-cp: Mark a non-exported function as staticAmmar Faizi
Functions that are not used outside the translation unit should be static. Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org> Link: https://lore.kernel.org/r/20221124162633.3856761-7-ammar.faizi@intel.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
5 daysucontext-cp: Remove an unused functionAmmar Faizi
When marking all internal functions as static after an attempt to integrate `-Wmissing-prototypes` flag. An unused function is found: ucontext-cp.c:71:12: error: ‘await_poll’ defined but not used [-Werror=unused-function] 71 | static int await_poll(async_context *pctx, int fd, short poll_mask) | ^~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:36: ucontext-cp] Error 1 Remove it. Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org> Link: https://lore.kernel.org/r/20221124162633.3856761-5-ammar.faizi@intel.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-09-21examples: fix sendzc notif handlingPavel Begunkov
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/e9a14d6e6b3dc7db4eb4f816abee59b947ce416e.1663759148.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-09-02examples: adjust zc bench to the new uapiPavel Begunkov
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/4d08a85d62101e0137cf2bd3587c45bd14667655.1662116617.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-08-05io_uring-udp: make more obvious what kernel version is requiredDylan Yudaken
This example uses some of the latest kernel features, which can be confusing. Make this clear in the error messages from these features that a latest kernel version is required. Signed-off-by: Dylan Yudaken <dylany@fb.com> Link: https://lore.kernel.org/r/20220803155741.3668818-1-dylany@fb.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-07-26examples/io_uring-udp: Use a proper cast for `(struct sockaddr *)` argumentAmmar Faizi
Sometimes the compiler accepts `(struct sockaddr_in *)` and `(struct sockaddr_in6 *)` to be passed in to `(struct sockaddr *)` without a cast. But not all compilers agree with that. Building with clang 13.0.1 yields the following errors: io_uring-udp.c:134:18: error: incompatible pointer types passing \ 'struct sockaddr_in6 *' to parameter of type 'const struct sockaddr *' \ [-Werror,-Wincompatible-pointer-types io_uring-udp.c:142:18: error: incompatible pointer types passing \ 'struct sockaddr_in *' to parameter of type 'const struct sockaddr *' \ [-Werror,-Wincompatible-pointer-types] Explicitly cast the pointer to (struct sockaddr *) to avoid this error. Cc: Dylan Yudaken <dylany@fb.com> Cc: Facebook Kernel Team <kernel-team@fb.com> Fixes: 61d472b51e761e61cbf46caea40aaf40d8ed1484 ("add an example for a UDP server") Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org> Link: https://lore.kernel.org/r/20220726164310.266060-1-ammar.faizi@intel.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-07-26add an example for a UDP serverDylan Yudaken
Add an example showing off multishot recvmsg and provided buffer rings. The application is a UDP echo server that responds to all packets with the same packet. Signed-off-by: Dylan Yudaken <dylany@fb.com> Link: https://lore.kernel.org/r/20220726121502.1958288-6-dylany@fb.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-07-25examples: add a zerocopy send examplePavel Begunkov
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/60f2a1a167b12fe60bf04d4c67da75a4a6983855.1658748624.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-07-22examples: add a simple single-shot poll benchmarkPavel Begunkov
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/20a5afbb4f8aeb586b6ce04a623264f18c4fe467.1658484803.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-03-10examples/Makefile: Add liburing.a as a dependencyAlviro Iskandar Setiawan
The example binaries statically link liburing using liburing.a file. When liburing.a is recompiled, make sure the example binaries are also recompiled to ensure changes are applied to the binaries. It makes "make clean" command optional when making changes. Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org> Link: https://lore.kernel.org/r/20220310111231.1713588-5-alviro.iskandar@gnuweeb.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-02-19Fix warnings/errors when compiling on Alpine LinuxMahdi Rakhshandehroo
Silences the following: * Error due to no definition for `mode_t` in `liburing.h` * Warning due to use of non-portable `#include <sys/poll.h>` and `#include <sys/signal.h>` * Warning due to incorrect `printf` format specifier in `test/io_uring_register.c` * Error due to missing declaration for `strcpy` in `test/sendmsg_fs_cve.c` * Error due to missing declaration for `strerror` in `test/shutdown.c` Signed-off-by: Mahdi Rakhshandehroo <mahdi.rakhshandehroo@gmail.com>
2022-01-28examples/link-cp.c: fix the last file-block retry may overflowMingqiang Sun
Signed-off-by: Mingqiang Sun <mingqiang.sun@esgyn.cn>
2021-12-23examples/io_uring_cp: fix bug while re-queuingmonte
Add io_uring_submit after queue_prepped while re-queuing sqe. Signed-off-by: monte <wm.april@gmail.com>
2021-10-31examples/Makefile: Fix missing clean upAmmar Faizi
Several things go wrong with this Makefile: 1) Using `test_srcs` to generate `test_objs`. 2) `test_objs` is an unused variable. So (1) is pointless. 3) `make clean` does not remove `ucontext-cp` binary. I assume (1) and (2) were blindly copied from the test Makefile. For 3, the `make clean` removes $(all_targets) and $(test_objs). But `ucontext-cp` only exists in $(all_targets) if we have `CONFIG_HAVE_UCONTEXT`. When the target goal is `clean`, we will not have any of `CONFIG_*` variables. Thus, `ucontext-cp` is not removed. Clean them up! Signed-off-by: Ammar Faizi <ammar.faizi@students.amikom.ac.id> Link: https://lore.kernel.org/r/20211030114858.320116-2-ammar.faizi@intel.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-10-18Revert "examples/ucontext-cp.c: Do not use SIGSTKSZ"Jens Axboe
This reverts commit af31ce2cbfcaecc2a6f342532ede5e293a34f7f7. The commit is buggy and causes ucontext-cp to crash. Just revert it for now. Fixes: https://github.com/axboe/liburing/issues/459 Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-09-17Merge branch 'master' of https://github.com/kraj/liburingJens Axboe
* 'master' of https://github.com/kraj/liburing: examples/ucontext-cp.c: Do not use SIGSTKSZ
2021-09-15examples: Fix warnings for comparison of integers with different signednessGuillem Jover
Warned-by: gcc -Wsign-compare Signed-off-by: Guillem Jover <guillem@hadrons.org>
2021-09-13build: Fix build flags supportGuillem Jover
The usual convention is that the various *FLAGS are user controllable, and can be overridden, so anything that is essential for the build should be passed respecting that. The other usual convention is that CPPFLAGS only contain pre-processor options, CFLAGS and CXXFLAGS only contain compilation options and LDFLAGS only contain linker flags, where all of these are honored in all build rules. Switch to set optional flags conditionally into the *FLAGS variables if they are not set, and then unconditionally append any required flags. And pass the various *FLAGS to the rules as expected. Signed-off-by: Guillem Jover <guillem@hadrons.org>
2021-09-02build: add -D_GNU_SOURCE to all CPPFLAGS/CFLAGS.Uman Shahzad
Needed for e.g. musl libc which only includes entities like cpu_set_t if this is defined. Signed-off-by: Uman Shahzad <uman@mslm.io>
2021-05-04examples/ucontext-cp.c: Do not use SIGSTKSZKhem Raj
glibc 2.34 has removed SIGSTKSZ therefore we replace it Signed-off-by: Khem Raj <raj.khem@gmail.com>
2021-04-20examples/link-cp: fix a couple of strerror negationsDavid Disseldorp
Signed-off-by: David Disseldorp <ddiss@suse.de>
2021-04-13examples/ucontext-cp.c: cope with variable SIGSTKSZStefan Hajnoczi
The size of C arrays at file scope must be constant. The following compiler error occurs with recent upstream glibc (2.33.9000): CC ucontext-cp ucontext-cp.c:31:23: error: variably modified ‘stack_buf’ at file scope 31 | unsigned char stack_buf[SIGSTKSZ]; | ^~~~~~~~~ make[1]: *** [Makefile:26: ucontext-cp] Error 1 The following glibc commit changed SIGSTKSZ from a constant value to a variable: commit 6c57d320484988e87e446e2e60ce42816bf51d53 Author: H.J. Lu <hjl.tools@gmail.com> Date: Mon Feb 1 11:00:38 2021 -0800 sysconf: Add _SC_MINSIGSTKSZ/_SC_SIGSTKSZ [BZ #20305] ... +# define SIGSTKSZ sysconf (_SC_SIGSTKSZ) Allocate the stack buffer explicitly to avoid declaring an array at file scope. Cc: H.J. Lu <hjl.tools@gmail.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-03-26examples/io_uring-cp: wait for pending writes before exit copy loopJens Axboe
We could be ending the loop with all reads done, but with pending writes that we haven't waited for yet. Ensure that we do so. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2020-10-28examples: disable ucontext-cp if ucontext.h is not availableSimon Zeni
The header file `ucontext.h` is not available on musl based distros. The example `ucontext-cp` is not built if `configure` fails to locate the header. Signed-off-by: Simon Zeni <simon@bl4ckb0ne.ca> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2020-09-20Fix build flag settingsGuillem Jover
Split preprocessor flags into CPPFLAGS to be passed to rules involving code compilation, instead of link-only rules. This also guarantees we always use the user set CPPFLAGS which are expected to be honored by most build systems. Move build system required C++ flags into an override for CXXFLAGS to follow the same pattern as the other flags. Signed-off-by: Guillem Jover <guillem@hadrons.org>
2020-08-20examples/io_uring-test: don't error on shorter filesJens Axboe
The example currently assumes the file is at least 4*4096 bytes, and errors when we get 0 reads on EOF. Fix this up. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2020-06-10examples/ucontext-cp.c: use IORING_OP_TIMEOUTCarter Li
2020-02-11Add SPDX license identifiersJens Axboe
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-12-23configure: allow to set host CCJens Axboe
Use ./configure --cc=whatever to set the compiler. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-12-23Makefile: quiet down rmJens Axboe
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-11-19Avoid redefined warning of "SIGSTKSZ"Jackie Liu
ucontext-cp.c:24:0: warning: "SIGSTKSZ" redefined #define SIGSTKSZ 8192 In file included from /usr/include/signal.h:316:0, from ucontext-cp.c:13: /usr/include/aarch64-linux-gnu/bits/sigstack.h:30:0: note: this is the location of the previous definition #define SIGSTKSZ 16384 Signed-off-by: Jackie Liu <liuyun01@kylinos.cn> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-10-01examples/ucontext-cp.c: get rid of c99 style declarationsJens Axboe
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-09-22Makefile: handle quiet AR/RANLIBJens Axboe
Also unify across subdirs. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-09-21Makefile: add pretty/quiet CC/LN outputJens Axboe
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-09-22examples/ucontext-cp: more complex example to show how ucontext works李通洲
Allow multiple files being copied in one command, and print more logs Also add timeout to indicate that different coroutines run in parallel actually Signed-off-by: 李通洲 <carter.li@eoitek.com>
2019-09-21Generalize Makefiles for examples and test.James Rouzier
Signed-off-by: James Rouzier <rouzier@gmail.com>
2019-09-20examples/ucontext-cp: style fixupsJens Axboe
No functional changes. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-09-20examples/ucontext-cp: use ucontext with liburing李通洲
Coroutines are often used to simplify async programming, and work great with liburing. `ucontext` doesn't perform very good, but it's enough for an example.
2019-08-30examples/io_uring-cp: handle io_uring_peek_cqe() -EAGAINJens Axboe
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-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-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-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-15examples/link-cp: improve memory useJens Axboe
Put the data at the end so we don't have to offset the actual buffer. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-15examples/link-cp: improvementsJens Axboe
Add short read requeue and abort on error. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-14examples/link-cp: fix a few issuesJens Axboe
Still need to handle broken chains, must resubmit those. Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-14Add chain failure handling test caseJens Axboe
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-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-17Separate test cases from examplesJens Axboe
Also adds a runtests makefile target.