Commit Graph

51 Commits

Author SHA1 Message Date
ohci1 4b8f3098a5 update configure info for 2.14
Co-authored-by: Pavel Begunkov<asml.silence@gmail.com>
Co-authored-by: Guillem Jover<guillem@hadrons.org>
Co-authored-by: Jens Axboe<axboe@kernel.dk>
Co-authored-by: Khem Raj<raj.khem@gmail.com>
Co-authored-by: Michael de Lang<kingoipo@gmail.com>
Co-authored-by: David Disseldorp<ddiss@suse.de>
Co-authored-by: Ming Lei<ming.lei@redhat.com>
2026-04-24 09:24:13 +08:00
zhongning5 19758392a5 delete code
Signed-off-by: zhongning5 <zhongning5@huawei.com>
2024-10-31 14:02:57 +08:00
fangzhiyi18 0ae77b95ef 升级2.7
Signed-off-by: fangzhiyi18 <fangzhiyi1@huawei.com>
2024-10-21 02:53:20 +00:00
Pavel Begunkov 1d3dfe7b6f examples: fix sendzc notif handling
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-21 09:00:26 -06:00
Pavel Begunkov 12db6a868a examples: adjust zc bench to the new uapi
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-09-02 05:56:53 -06:00
Dylan Yudaken 762792d393 io_uring-udp: make more obvious what kernel version is required
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-08-05 08:43:23 -06:00
Ammar Faizi 7bc3233e03 examples/io_uring-udp: Use a proper cast for (struct sockaddr *) argument
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: 12d7e7cf8f ("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-26 10:46:47 -06:00
Dylan Yudaken 12d7e7cf8f add an example for a UDP server
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-26 10:22:45 -06:00
Pavel Begunkov 7d554b8352 examples: add a zerocopy send example
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-25 09:46:23 -06:00
Pavel Begunkov b71741dc80 examples: add a simple single-shot poll benchmark
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-07-22 09:20:47 -06:00
Alviro Iskandar Setiawan 0acab8f6ff examples/Makefile: Add liburing.a as a dependency
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-03-10 05:13:49 -07:00
Mahdi Rakhshandehroo 8027807663 Fix warnings/errors when compiling on Alpine Linux
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-02-19 22:44:14 -08:00
Mingqiang Sun d82d461012 examples/link-cp.c: fix the last file-block retry may overflow
Signed-off-by: Mingqiang Sun <mingqiang.sun@esgyn.cn>
2022-01-28 22:06:07 +08:00
monte 28e895a3ff examples/io_uring_cp: fix bug while re-queuing
Add io_uring_submit after queue_prepped while re-queuing sqe.

Signed-off-by: monte <wm.april@gmail.com>
2021-12-23 12:04:58 +08:00
Ammar Faizi a8fbb6cf1d examples/Makefile: Fix missing clean up
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-31 16:30:00 -06:00
Jens Axboe 8b829b3308 Revert "examples/ucontext-cp.c: Do not use SIGSTKSZ"
This reverts commit 56ea856837.

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-10-18 11:12:25 -06:00
Jens Axboe 20f2507154 Merge branch 'master' of https://github.com/kraj/liburing
* 'master' of https://github.com/kraj/liburing:
  examples/ucontext-cp.c: Do not use SIGSTKSZ
2021-09-17 18:20:50 -06:00
Guillem Jover 588b162788 examples: Fix warnings for comparison of integers with different signedness
Warned-by: gcc -Wsign-compare
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2021-09-15 14:52:25 +02:00
Guillem Jover 130e82b9f2 build: Fix build flags support
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-13 13:19:25 +02:00
Uman Shahzad 5ebfd161d7 build: add -D_GNU_SOURCE to all CPPFLAGS/CFLAGS.
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-09-02 02:13:24 +05:00
Khem Raj 56ea856837 examples/ucontext-cp.c: Do not use SIGSTKSZ
glibc 2.34 has removed SIGSTKSZ therefore we replace it

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2021-05-04 19:05:52 -07:00
David Disseldorp 6cff14ec49 examples/link-cp: fix a couple of strerror negations
Signed-off-by: David Disseldorp <ddiss@suse.de>
2021-04-20 23:26:54 +02:00
Stefan Hajnoczi 53ed068d83 examples/ucontext-cp.c: cope with variable SIGSTKSZ
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-04-13 09:11:40 -06:00
Jens Axboe 827e0b7c27 examples/io_uring-cp: wait for pending writes before exit copy loop
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>
2021-03-26 07:18:45 -06:00
Simon Zeni 14540a9618 examples: disable ucontext-cp if ucontext.h is not available
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-10-28 16:32:16 -06:00
Guillem Jover a91f313e6a Fix build flag settings
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-09-20 03:10:52 +02:00
Jens Axboe 53b4f9af81 examples/io_uring-test: don't error on shorter files
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-08-20 05:48:24 -06:00
Carter Li 5e95ff2c30 examples/ucontext-cp.c: use IORING_OP_TIMEOUT 2020-06-10 15:54:22 +08:00
Jens Axboe e502435779 Add SPDX license identifiers
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2020-02-11 20:34:12 -07:00
Jens Axboe 4332433754 configure: allow to set host CC
Use ./configure --cc=whatever to set the compiler.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-12-23 21:34:03 -07:00
Jens Axboe 32fcace197 Makefile: quiet down rm
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-12-23 21:33:47 -07:00
Jackie Liu 6a273eaa1a Avoid redefined warning of "SIGSTKSZ"
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-11-19 20:35:56 -07:00
Jens Axboe 6bf626224e examples/ucontext-cp.c: get rid of c99 style declarations
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-10-01 16:08:35 -06:00
Jens Axboe 1cff0db7bc Makefile: handle quiet AR/RANLIB
Also unify across subdirs.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-09-22 10:10:33 -06:00
Jens Axboe ad551e6470 Makefile: add pretty/quiet CC/LN output
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-09-21 20:46:00 -06:00
李通洲 a05c7a6c89 examples/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-22 09:48:02 +08:00
James Rouzier e88b74ae6d Generalize Makefiles for examples and test.
Signed-off-by: James Rouzier <rouzier@gmail.com>
2019-09-21 17:16:50 -04:00
Jens Axboe 5109ed3ec7 examples/ucontext-cp: style fixups
No functional changes.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-09-20 07:13:07 -06:00
李通洲 20b3ce6c52 examples/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-09-20 17:37:55 +08:00
Jens Axboe b76db3f49d examples/io_uring-cp: handle io_uring_peek_cqe() -EAGAIN
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-08-30 11:09:46 -06:00
Stefan Hajnoczi c31c7ec4bc src/Makefile: keep private headers in <liburing/*.h>
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-24 09:11:44 -06:00
Bart Van Assche 64f89fa146 Makefiles: Support specifying CFLAGS on the command line
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-08 15:25:57 -06:00
Stephen Bates 733223acd6 example/io_uring-test.c: Fix iovecs increment
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-13 03:04:32 -06:00
zhangliguang 4d325561f3 examples/io_uring-cp: fix a NULL pointer dereference
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-22 08:46:28 -06:00
Jens Axboe 9511863658 examples/link-cp: improve memory use
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-15 14:11:10 -06:00
Jens Axboe 5c6e5d2745 examples/link-cp: improvements
Add short read requeue and abort on error.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-15 14:07:52 -06:00
Jens Axboe 7e8902e14c examples/link-cp: fix a few issues
Still need to handle broken chains, must resubmit those.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-14 20:46:12 -06:00
Jens Axboe 1982bfd44d Add chain failure handling test case
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-14 19:08:37 -06:00
Jens Axboe 0ba9503f79 Add link SQE support
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-13 16:16:07 -06:00
Jens Axboe 39e0ebd4fc Rename completion helpers
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-18 08:38:08 -06:00