pax_global_header 0000666 0000000 0000000 00000000064 14521531436 0014516 g ustar 00root root 0000000 0000000 52 comment=f4e42a515cd78c8c9cac2be14222834be5f8df2b
liburing-2.5/ 0000775 0000000 0000000 00000000000 14521531436 0013177 5 ustar 00root root 0000000 0000000 liburing-2.5/.github/ 0000775 0000000 0000000 00000000000 14521531436 0014537 5 ustar 00root root 0000000 0000000 liburing-2.5/.github/pull_request_template.md 0000664 0000000 0000000 00000005666 14521531436 0021515 0 ustar 00root root 0000000 0000000
----
## git request-pull output:
```
Generate your PR shortlog and diffstat with these commands:
git remote add axboe-tree https://github.com/axboe/liburing
git fetch axboe-tree
git request-pull axboe-tree/master your_fork_URL your_branch_name
Then replace this with the output of `git request-pull` command.
```
----
Click to show/hide pull request guidelines
## Pull Request Guidelines
1. To make everyone easily filter pull request from the email
notification, use `[GIT PULL]` as a prefix in your PR title.
```
[GIT PULL] Your Pull Request Title
```
2. Follow the commit message format rules below.
3. Follow the Linux kernel coding style (see: https://github.com/torvalds/linux/blob/master/Documentation/process/coding-style.rst).
### Commit message format rules:
1. The first line is title (don't be more than 72 chars if possible).
2. Then an empty line.
3. Then a description (may be omitted for truly trivial changes).
4. Then an empty line again (if it has a description).
5. Then a `Signed-off-by` tag with your real name and email. For example:
```
Signed-off-by: Foo Bar
```
The description should be word-wrapped at 72 chars. Some things should
not be word-wrapped. They may be some kind of quoted text - long
compiler error messages, oops reports, Link, etc. (things that have a
certain specific format).
Note that all of this goes in the commit message, not in the pull
request text. The pull request text should introduce what this pull
request does, and each commit message should explain the rationale for
why that particular change was made. The git tree is canonical source
of truth, not github.
Each patch should do one thing, and one thing only. If you find yourself
writing an explanation for why a patch is fixing multiple issues, that's
a good indication that the change should be split into separate patches.
If the commit is a fix for an issue, add a `Fixes` tag with the issue
URL.
Don't use GitHub anonymous email like this as the commit author:
```
123456789+username@users.noreply.github.com
```
Use a real email address!
### Commit message example:
```
src/queue: don't flush SQ ring for new wait interface
If we have IORING_FEAT_EXT_ARG, then timeouts are done through the
syscall instead of by posting an internal timeout. This was done
to be both more efficient, but also to enable multi-threaded use
the wait side. If we touch the SQ state by flushing it, that isn't
safe without synchronization.
Fixes: https://github.com/axboe/liburing/issues/402
Signed-off-by: Jens Axboe
```
----
## By submitting this pull request, I acknowledge that:
1. I have followed the above pull request guidelines.
2. I have the rights to submit this work under the same license.
3. I agree to a Developer Certificate of Origin (see https://developercertificate.org for more information).
liburing-2.5/.github/workflows/ 0000775 0000000 0000000 00000000000 14521531436 0016574 5 ustar 00root root 0000000 0000000 liburing-2.5/.github/workflows/build.yml 0000664 0000000 0000000 00000010040 14521531436 0020411 0 ustar 00root root 0000000 0000000 name: Build test
on:
# Trigger the workflow on push or pull requests.
push:
pull_request:
jobs:
build:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
# x86-64 gcc
- arch: x86_64
cc_pkg: gcc-x86-64-linux-gnu
cxx_pkg: g++-x86-64-linux-gnu
cc: x86_64-linux-gnu-gcc
cxx: x86_64-linux-gnu-g++
# x86-64 clang
- arch: x86_64
cc_pkg: clang
cxx_pkg: clang
cc: clang
cxx: clang++
liburing_extra_flags: -Wshorten-64-to-32
extra_flags: -Wmissing-prototypes -Wstrict-prototypes -Wunreachable-code-loop-increment -Wunreachable-code -Wmissing-variable-declarations -Wextra-semi-stmt
# x86 (32-bit) gcc
- arch: i686
cc_pkg: gcc-i686-linux-gnu
cxx_pkg: g++-i686-linux-gnu
cc: i686-linux-gnu-gcc
cxx: i686-linux-gnu-g++
# aarch64 gcc
- arch: aarch64
cc_pkg: gcc-aarch64-linux-gnu
cxx_pkg: g++-aarch64-linux-gnu
cc: aarch64-linux-gnu-gcc
cxx: aarch64-linux-gnu-g++
# arm (32-bit) gcc
- arch: arm
cc_pkg: gcc-arm-linux-gnueabi
cxx_pkg: g++-arm-linux-gnueabi
cc: arm-linux-gnueabi-gcc
cxx: arm-linux-gnueabi-g++
# riscv64
- arch: riscv64
cc_pkg: gcc-riscv64-linux-gnu
cxx_pkg: g++-riscv64-linux-gnu
cc: riscv64-linux-gnu-gcc
cxx: riscv64-linux-gnu-g++
# powerpc64
- arch: powerpc64
cc_pkg: gcc-powerpc64-linux-gnu
cxx_pkg: g++-powerpc64-linux-gnu
cc: powerpc64-linux-gnu-gcc
cxx: powerpc64-linux-gnu-g++
# powerpc
- arch: powerpc
cc_pkg: gcc-powerpc-linux-gnu
cxx_pkg: g++-powerpc-linux-gnu
cc: powerpc-linux-gnu-gcc
cxx: powerpc-linux-gnu-g++
# alpha
- arch: alpha
cc_pkg: gcc-alpha-linux-gnu
cxx_pkg: g++-alpha-linux-gnu
cc: alpha-linux-gnu-gcc
cxx: alpha-linux-gnu-g++
# mips64
- arch: mips64
cc_pkg: gcc-mips64-linux-gnuabi64
cxx_pkg: g++-mips64-linux-gnuabi64
cc: mips64-linux-gnuabi64-gcc
cxx: mips64-linux-gnuabi64-g++
# mips
- arch: mips
cc_pkg: gcc-mips-linux-gnu
cxx_pkg: g++-mips-linux-gnu
cc: mips-linux-gnu-gcc
cxx: mips-linux-gnu-g++
# hppa
- arch: hppa
cc_pkg: gcc-hppa-linux-gnu
cxx_pkg: g++-hppa-linux-gnu
cc: hppa-linux-gnu-gcc
cxx: hppa-linux-gnu-g++
env:
FLAGS: -g -O3 -Wall -Wextra -Werror -Wno-sign-compare ${{matrix.extra_flags}}
# Flags for building sources in src/ dir only.
LIBURING_CFLAGS: ${{matrix.liburing_extra_flags}}
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Install Compilers
run: |
if [[ "${{matrix.cc_pkg}}" == "clang" ]]; then \
wget https://apt.llvm.org/llvm.sh -O /tmp/llvm.sh; \
sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14 -y; \
sudo bash /tmp/llvm.sh 17; \
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-17 400; \
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-17 400; \
else \
sudo apt-get update -y; \
sudo apt-get install -y ${{matrix.cc_pkg}} ${{matrix.cxx_pkg}}; \
fi;
- name: Display compiler versions
run: |
${{matrix.cc}} --version;
${{matrix.cxx}} --version;
- name: Build
run: |
./configure --cc=${{matrix.cc}} --cxx=${{matrix.cxx}};
make -j$(nproc) V=1 CPPFLAGS="-Werror" CFLAGS="$FLAGS" CXXFLAGS="$FLAGS";
- name: Test install command
run: |
sudo make install;
liburing-2.5/.github/workflows/shellcheck.yml 0000664 0000000 0000000 00000000543 14521531436 0021426 0 ustar 00root root 0000000 0000000 name: Shellcheck
on:
# Trigger the workflow on push or pull requests.
push:
pull_request:
jobs:
test:
runs-on: ubuntu-22.04
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Display shellcheck version
run: shellcheck --version
- name: Shellcheck execution
run: shellcheck test/runtest*.sh
liburing-2.5/.gitignore 0000664 0000000 0000000 00000001016 14521531436 0015165 0 ustar 00root root 0000000 0000000 *.rej
*.orig
*~
/*.patch
*.d
*.o
*.o[ls]
/src/liburing.a
/src/liburing.so*
/src/liburing-ffi.a
/src/liburing-ffi.so*
/src/include/liburing/compat.h
/src/include/liburing/io_uring_version.h
/examples/io_uring-close-test
/examples/io_uring-cp
/examples/io_uring-test
/examples/io_uring-udp
/examples/link-cp
/examples/ucontext-cp
/examples/poll-bench
/examples/send-zerocopy
/examples/rsrc-update-bench
/test/*.t
/test/*.dmesg
/test/output/
config-host.h
config-host.mak
config.log
liburing.pc
liburing-ffi.pc
cscope.out
liburing-2.5/CHANGELOG 0000664 0000000 0000000 00000006432 14521531436 0014416 0 ustar 00root root 0000000 0000000 liburing-2.5 release
- Add support for io_uring_prep_cmd_sock()
- Add support for application allocated ring memory, for placing rings
in huge mem. Available through io_uring_queue_init_mem().
- Add support for registered ring fds
- Various documentation updates
- Various fixes
liburing-2.4 release
- Add io_uring_{major,minor,check}_version() functions.
- Add IO_URING_{MAJOR,MINOR,CHECK}_VERSION() macros.
- FFI support (for non-C/C++ languages integration).
- Add io_uring_prep_msg_ring_cqe_flags() function.
- Deprecate --nolibc configure option.
- CONFIG_NOLIBC is always enabled on x86-64, x86, and aarch64.
- Add support for IORING_REGISTER_USE_REGISTERED_RING and use if available.
- Add io_uring_close_ring_fd() function.
- Add io_uring_prep_msg_ring_fd_alloc function.
- Add io_uring_free_buf_ring() and io_uring_setup_buf_ring() functions.
- Ensure that io_uring_prep_accept_direct(), io_uring_prep_openat_direct(),
io_uring_prep_openat2_direct(), io_uring_prep_msg_ring_fd(), and
io_uring_prep_socket_direct() factor in being called with
IORING_FILE_INDEX_ALLOC for allocating a direct descriptor.
- Add io_uring_prep_sendto() function.
- Add io_uring_prep_cmd_sock() function.
liburing-2.3 release
- Support non-libc build for aarch64.
- Add io_uring_{enter,enter2,register,setup} syscall functions.
- Add sync cancel interface, io_uring_register_sync_cancel().
- Fix return value of io_uring_submit_and_wait_timeout() to match the
man page.
- Improvements to the regression tests
- Add support and test case for passthrough IO
- Add recv and recvmsg multishot helpers and support
- Add documentation and support for IORING_SETUP_DEFER_TASKRUN
- Fix potential missing kernel entry with IORING_SETUP_IOPOLL
- Add support and documentation for zero-copy network transmit
- Various optimizations
- Many cleanups
- Many man page additions and updates
liburing-2.2 release
- Support non-libc builds.
- Optimized syscall handling for x86-64/x86/aarch64.
- Enable non-lib function calls for fast path functions.
- Add support for multishot accept.
- io_uring_register_files() will set RLIMIT_NOFILE if necessary.
- Add support for registered ring fds, io_uring_register_ring_fd(),
reducing the overhead of an io_uring_enter() system call.
- Add support for the message ring opcode.
- Add support for newer request cancelation features.
- Add support for IORING_SETUP_COOP_TASKRUN, which can help reduce the
overhead of io_uring in general. Most applications should set this flag,
see the io_uring_setup.2 man page for details.
- Add support for registering a sparse buffer and file set.
- Add support for a new buffer provide scheme, see
io_uring_register_buf_ring.3 for details.
- Add io_uring_submit_and_wait_timeout() for submitting IO and waiting
for completions with a timeout.
- Add io_uring_prep_{read,write}v2 prep helpers.
- Add io_uring_prep_close_direct() helper.
- Add support for SQE128 and CQE32, which are doubly sized SQE and CQE
rings. This is needed for some cases of the new IORING_OP_URING_CMD,
notably for NVMe passthrough.
- ~5500 lines of man page additions, including adding ~90 new man pages.
- Synced with the 5.19 kernel release, supporting all the features of
5.19 and earlier.
- 24 new regression test cases, and ~7000 lines of new tests in general.
- General optimizations and fixes.
liburing-2.5/CITATION.cff 0000664 0000000 0000000 00000000364 14521531436 0015074 0 ustar 00root root 0000000 0000000 cff-version: 1.2.0
preferred-citation:
type: software
authors:
- family-names: "Axboe"
given-names: "Jens"
email: axboe@kernel.dk
title: "liburing library for io_uring"
year: 2022
url: "https://github.com/axboe/liburing"
licence: MIT
liburing-2.5/COPYING 0000664 0000000 0000000 00000063631 14521531436 0014243 0 ustar 00root root 0000000 0000000 GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
Copyright (C)
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.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
liburing-2.5/COPYING.GPL 0000664 0000000 0000000 00000043254 14521531436 0014663 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
liburing-2.5/LICENSE 0000664 0000000 0000000 00000002032 14521531436 0014201 0 ustar 00root root 0000000 0000000 Copyright 2020 Jens Axboe
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
liburing-2.5/Makefile 0000664 0000000 0000000 00000004476 14521531436 0014652 0 ustar 00root root 0000000 0000000 include Makefile.common
RPMBUILD=$(shell `which rpmbuild >&/dev/null` && echo "rpmbuild" || echo "rpm")
INSTALL=install
default: all
all:
@$(MAKE) -C src
@$(MAKE) -C test
@$(MAKE) -C examples
.PHONY: all install default clean test
.PHONY: FORCE cscope
partcheck: all
@echo "make partcheck => TODO add tests with out kernel support"
runtests: all
@$(MAKE) -C test runtests
runtests-loop: all
@$(MAKE) -C test runtests-loop
runtests-parallel: all
@$(MAKE) -C test runtests-parallel
config-host.mak: configure
+@if [ ! -e "$@" ]; then \
echo "Running configure ..."; \
./configure; \
else \
echo "$@ is out-of-date, running configure"; \
sed -n "/.*Configured with/s/[^:]*: //p" "$@" | sh; \
fi
ifneq ($(MAKECMDGOALS),clean)
include config-host.mak
endif
%.pc: %.pc.in config-host.mak $(SPECFILE)
sed -e "s%@prefix@%$(prefix)%g" \
-e "s%@libdir@%$(libdir)%g" \
-e "s%@includedir@%$(includedir)%g" \
-e "s%@NAME@%$(NAME)%g" \
-e "s%@VERSION@%$(VERSION)%g" \
$< >$@
install: $(NAME).pc $(NAME)-ffi.pc
@$(MAKE) -C src install prefix=$(DESTDIR)$(prefix) \
includedir=$(DESTDIR)$(includedir) \
libdir=$(DESTDIR)$(libdir) \
libdevdir=$(DESTDIR)$(libdevdir) \
relativelibdir=$(relativelibdir)
$(INSTALL) -D -m 644 $(NAME).pc $(DESTDIR)$(libdevdir)/pkgconfig/$(NAME).pc
$(INSTALL) -D -m 644 $(NAME)-ffi.pc $(DESTDIR)$(libdevdir)/pkgconfig/$(NAME)-ffi.pc
$(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man2
$(INSTALL) -m 644 man/*.2 $(DESTDIR)$(mandir)/man2
$(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man3
$(INSTALL) -m 644 man/*.3 $(DESTDIR)$(mandir)/man3
$(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man7
$(INSTALL) -m 644 man/*.7 $(DESTDIR)$(mandir)/man7
install-tests:
@$(MAKE) -C test install prefix=$(DESTDIR)$(prefix) datadir=$(DESTDIR)$(datadir)
clean:
@rm -f config-host.mak config-host.h cscope.out $(NAME).pc $(NAME)-ffi.pc test/*.dmesg
@$(MAKE) -C src clean
@$(MAKE) -C test clean
@$(MAKE) -C examples clean
cscope:
@cscope -b -R
tag-archive:
@git tag $(TAG)
create-archive:
@git archive --prefix=$(NAME)-$(VERSION)/ -o $(NAME)-$(VERSION).tar.gz $(TAG)
@echo "The final archive is ./$(NAME)-$(VERSION).tar.gz."
archive: clean tag-archive create-archive
srpm: create-archive
$(RPMBUILD) --define "_sourcedir `pwd`" --define "_srcrpmdir `pwd`" --nodeps -bs $(SPECFILE)
liburing-2.5/Makefile.common 0000664 0000000 0000000 00000000465 14521531436 0016133 0 ustar 00root root 0000000 0000000 TOP := $(dir $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
NAME=liburing
SPECFILE=$(TOP)/$(NAME).spec
VERSION=$(shell awk '/Version:/ { print $$2 }' $(SPECFILE))
VERSION_MAJOR=$(shell echo $(VERSION) | cut -d. -f1)
VERSION_MINOR=$(shell echo $(VERSION) | cut -d. -f2)
TAG = $(NAME)-$(VERSION)
liburing-2.5/Makefile.quiet 0000664 0000000 0000000 00000000355 14521531436 0015770 0 ustar 00root root 0000000 0000000 ifneq ($(findstring $(MAKEFLAGS),s),s)
ifndef V
QUIET_CC = @echo ' ' CC $@;
QUIET_CXX = @echo ' ' CXX $@;
QUIET_LINK = @echo ' ' LINK $@;
QUIET_AR = @echo ' ' AR $@;
QUIET_RANLIB = @echo '' RANLIB $@;
endif
endif
liburing-2.5/README 0000664 0000000 0000000 00000006000 14521531436 0014053 0 ustar 00root root 0000000 0000000 liburing
--------
This is the io_uring library, liburing. liburing provides helpers to setup and
teardown io_uring instances, and also a simplified interface for
applications that don't need (or want) to deal with the full kernel
side implementation.
For more info on io_uring, please see:
https://kernel.dk/io_uring.pdf
Subscribe to io-uring@vger.kernel.org for io_uring related discussions
and development for both kernel and userspace. The list is archived here:
https://lore.kernel.org/io-uring/
kernel version dependency
--------------------------
liburing itself is not tied to any specific kernel release, and hence it's
possible to use the newest liburing release even on older kernels (and vice
versa). Newer features may only be available on more recent kernels,
obviously.
ulimit settings
---------------
io_uring accounts memory it needs under the rlimit memlocked option, which
can be quite low on some setups (64K). The default is usually enough for
most use cases, but bigger rings or things like registered buffers deplete
it quickly. root isn't under this restriction, but regular users are. Going
into detail on how to bump the limit on various systems is beyond the scope
of this little blurb, but check /etc/security/limits.conf for user specific
settings, or /etc/systemd/user.conf and /etc/systemd/system.conf for systemd
setups. This affects 5.11 and earlier, new kernels are less dependent
on RLIMIT_MEMLOCK as it is only used for registering buffers.
Regressions tests
-----------------
The bulk of liburing is actually regression/unit tests for both liburing and
the kernel io_uring support. Please note that this suite isn't expected to
pass on older kernels, and may even crash or hang older kernels!
Building liburing
-----------------
#
# Prepare build config (optional).
#
# --cc specifies the C compiler.
# --cxx speficies the C++ compiler.
#
./configure --cc=gcc --cxx=g++;
#
# Build liburing.
#
make -j$(nproc);
#
# Install liburing (headers, shared/static libs, and manpage).
#
sudo make install;
See './configure --help' for more information about build config options.
FFI support
-----------
By default, the build results in 4 lib files:
2 shared libs:
liburing.so
liburing-ffi.so
2 static libs:
liburing.a
liburing-ffi.a
Languages and applications that can't use 'static inline' functions in
liburing.h should use the FFI variants.
liburing's main public interface lives in liburing.h as 'static inline'
functions. Users wishing to consume liburing purely as a binary dependency
should link against liburing-ffi. It contains definitions for every 'static
inline' function.
License
-------
All software contained within this repo is dual licensed LGPL and MIT, see
COPYING and LICENSE, except for a header coming from the kernel which is
dual licensed GPL with a Linux-syscall-note exception and MIT, see
COPYING.GPL and .
Jens Axboe 2022-05-19
liburing-2.5/SECURITY.md 0000664 0000000 0000000 00000000316 14521531436 0014770 0 ustar 00root root 0000000 0000000 # Security Policy
## Reporting a Vulnerability
Please report any security issue to axboe@kernel.dk where the issue will be triaged appropriately.
Thank you in advance for helping to keep liburing secure.
liburing-2.5/configure 0000775 0000000 0000000 00000030726 14521531436 0015116 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
cc=${CC:-gcc}
cxx=${CXX:-g++}
for opt do
optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)' || true)
case "$opt" in
--help|-h) show_help=yes
;;
--prefix=*) prefix="$optarg"
;;
--includedir=*) includedir="$optarg"
;;
--libdir=*) libdir="$optarg"
;;
--libdevdir=*) libdevdir="$optarg"
;;
--mandir=*) mandir="$optarg"
;;
--datadir=*) datadir="$optarg"
;;
--cc=*) cc="$optarg"
;;
--cxx=*) cxx="$optarg"
;;
--use-libc) use_libc=yes
;;
*)
echo "ERROR: unknown option $opt"
echo "Try '$0 --help' for more information"
exit 1
;;
esac
done
if test -z "$prefix"; then
prefix=/usr
fi
if test -z "$includedir"; then
includedir="$prefix/include"
fi
if test -z "$libdir"; then
libdir="$prefix/lib"
fi
if test -z "$libdevdir"; then
libdevdir="$prefix/lib"
fi
if test -z "$mandir"; then
mandir="$prefix/man"
fi
if test -z "$datadir"; then
datadir="$prefix/share"
fi
if test x"$libdir" = x"$libdevdir"; then
relativelibdir=""
else
relativelibdir="$libdir/"
fi
if test "$show_help" = "yes"; then
cat <
trap "rm -rf $TMP_DIRECTORY" EXIT INT QUIT TERM
rm -rf config.log
config_host_mak="config-host.mak"
config_host_h="config-host.h"
rm -rf $config_host_mak
rm -rf $config_host_h
fatal() {
echo $@
echo "Configure failed, check config.log and/or the above output"
rm -rf $config_host_mak
rm -rf $config_host_h
exit 1
}
# Print result for each configuration test
print_config() {
printf "%-30s%s\n" "$1" "$2"
}
# Default CFLAGS
CFLAGS="-D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -include config-host.h"
BUILD_CFLAGS=""
# Print configure header at the top of $config_host_h
echo "/*" > $config_host_h
echo " * Automatically generated by configure - do not modify" >> $config_host_h
printf " * Configured with:" >> $config_host_h
printf " * '%s'" "$0" "$@" >> $config_host_h
echo "" >> $config_host_h
echo " */" >> $config_host_h
echo "# Automatically generated by configure - do not modify" > $config_host_mak
printf "# Configured with:" >> $config_host_mak
printf " '%s'" "$0" "$@" >> $config_host_mak
echo >> $config_host_mak
do_cxx() {
# Run the compiler, capturing its output to the log.
echo $cxx "$@" >> config.log
$cxx "$@" >> config.log 2>&1 || return $?
return 0
}
do_cc() {
# Run the compiler, capturing its output to the log.
echo $cc "$@" >> config.log
$cc "$@" >> config.log 2>&1 || return $?
# Test passed. If this is an --enable-werror build, rerun
# the test with -Werror and bail out if it fails. This
# makes warning-generating-errors in configure test code
# obvious to developers.
if test "$werror" != "yes"; then
return 0
fi
# Don't bother rerunning the compile if we were already using -Werror
case "$*" in
*-Werror*)
return 0
;;
esac
echo $cc -Werror "$@" >> config.log
$cc -Werror "$@" >> config.log 2>&1 && return $?
echo "ERROR: configure test passed without -Werror but failed with -Werror."
echo "This is probably a bug in the configure script. The failing command"
echo "will be at the bottom of config.log."
fatal "You can run configure with --disable-werror to bypass this check."
}
compile_prog() {
local_cflags="$1"
local_ldflags="$2 $LIBS"
echo "Compiling test case $3" >> config.log
do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
}
compile_prog_cxx() {
local_cflags="$1"
local_ldflags="$2 $LIBS"
echo "Compiling test case $3" >> config.log
do_cxx $CFLAGS $local_cflags -o $TMPE $TMPCXX $LDFLAGS $local_ldflags
}
has() {
type "$1" >/dev/null 2>&1
}
output_mak() {
echo "$1=$2" >> $config_host_mak
}
output_sym() {
output_mak "$1" "y"
echo "#define $1" >> $config_host_h
}
print_and_output_mak() {
print_config "$1" "$2"
output_mak "$1" "$2"
}
print_and_output_mak "prefix" "$prefix"
print_and_output_mak "includedir" "$includedir"
print_and_output_mak "libdir" "$libdir"
print_and_output_mak "libdevdir" "$libdevdir"
print_and_output_mak "relativelibdir" "$relativelibdir"
print_and_output_mak "mandir" "$mandir"
print_and_output_mak "datadir" "$datadir"
##########################################
# check for compiler -Wstringop-overflow
stringop_overflow="no"
cat > $TMPC << EOF
#include
int main(int argc, char **argv)
{
return 0;
}
EOF
if compile_prog "-Werror -Wstringop-overflow=0" "" "stringop_overflow"; then
stringop_overflow="yes"
fi
print_config "stringop_overflow" "$stringop_overflow"
##########################################
# check for compiler -Warryr-bounds
array_bounds="no"
cat > $TMPC << EOF
#include
int main(int argc, char **argv)
{
return 0;
}
EOF
if compile_prog "-Werror -Warray-bounds=0" "" "array_bounds"; then
array_bounds="yes"
fi
print_config "array_bounds" "$array_bounds"
##########################################
# check for __kernel_rwf_t
__kernel_rwf_t="no"
cat > $TMPC << EOF
#include
int main(int argc, char **argv)
{
__kernel_rwf_t x;
x = 0;
return x;
}
EOF
if compile_prog "" "" "__kernel_rwf_t"; then
__kernel_rwf_t="yes"
fi
print_config "__kernel_rwf_t" "$__kernel_rwf_t"
##########################################
# check for __kernel_timespec
__kernel_timespec="no"
cat > $TMPC << EOF
#include
#include
int main(int argc, char **argv)
{
struct __kernel_timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 1;
return 0;
}
EOF
if compile_prog "" "" "__kernel_timespec"; then
__kernel_timespec="yes"
fi
print_config "__kernel_timespec" "$__kernel_timespec"
##########################################
# check for open_how
open_how="no"
cat > $TMPC << EOF
#include
#include
#include
#include
int main(int argc, char **argv)
{
struct open_how how;
how.flags = 0;
how.mode = 0;
how.resolve = 0;
return 0;
}
EOF
if compile_prog "" "" "open_how"; then
open_how="yes"
fi
print_config "open_how" "$open_how"
##########################################
# check for statx
statx="no"
cat > $TMPC << EOF
#include
#include
#include
#include
#include
int main(int argc, char **argv)
{
struct statx x;
return memset(&x, 0, sizeof(x)) != NULL;
}
EOF
if compile_prog "" "" "statx"; then
statx="yes"
fi
print_config "statx" "$statx"
##########################################
# check for glibc statx
glibc_statx="no"
cat > $TMPC << EOF
#include
#include
#include
#include
#include
int main(int argc, char **argv)
{
struct statx x;
return memset(&x, 0, sizeof(x)) != NULL;
}
EOF
if compile_prog "" "" "glibc_statx"; then
glibc_statx="yes"
fi
print_config "glibc_statx" "$glibc_statx"
##########################################
# check for C++
has_cxx="no"
cat > $TMPCXX << EOF
#include
int main(int argc, char **argv)
{
std::cout << "Test";
return 0;
}
EOF
if compile_prog_cxx "" "" "C++"; then
has_cxx="yes"
fi
print_config "C++" "$has_cxx"
##########################################
# check for ucontext support
has_ucontext="no"
cat > $TMPC << EOF
#include
int main(int argc, char **argv)
{
ucontext_t ctx;
getcontext(&ctx);
makecontext(&ctx, 0, 0);
return 0;
}
EOF
if compile_prog "" "" "has_ucontext"; then
has_ucontext="yes"
fi
print_config "has_ucontext" "$has_ucontext"
##########################################
# Check NVME_URING_CMD support
nvme_uring_cmd="no"
cat > $TMPC << EOF
#include
int main(void)
{
struct nvme_uring_cmd *cmd;
return sizeof(struct nvme_uring_cmd);
}
EOF
if compile_prog "" "" "nvme uring cmd"; then
nvme_uring_cmd="yes"
fi
print_config "NVMe uring command support" "$nvme_uring_cmd"
#############################################################################
liburing_nolibc="no"
if test "$use_libc" != "yes"; then
#
# Currently, CONFIG_NOLIBC only supports x86-64, x86 (32-bit), aarch64 and riscv64.
#
cat > $TMPC << EOF
int main(void){
#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || (defined(__riscv) && __riscv_xlen == 64)
return 0;
#else
#error libc is needed
#endif
}
EOF
if compile_prog "" "" "nolibc"; then
liburing_nolibc="yes"
fi
fi
print_config "nolibc" "$liburing_nolibc";
#############################################################################
####################################################
# Most Android devices don't have sys/fanotify.h
has_fanotify="no"
cat > $TMPC << EOF
#include
int main(void)
{
return 0;
}
EOF
if compile_prog "" "" "fanotify"; then
has_fanotify="yes"
fi
print_config "has_fanotify" "$has_fanotify"
####################################################
if test "$liburing_nolibc" = "yes"; then
output_sym "CONFIG_NOLIBC"
fi
if test "$__kernel_rwf_t" = "yes"; then
output_sym "CONFIG_HAVE_KERNEL_RWF_T"
fi
if test "$__kernel_timespec" = "yes"; then
output_sym "CONFIG_HAVE_KERNEL_TIMESPEC"
fi
if test "$open_how" = "yes"; then
output_sym "CONFIG_HAVE_OPEN_HOW"
fi
if test "$statx" = "yes"; then
output_sym "CONFIG_HAVE_STATX"
fi
if test "$glibc_statx" = "yes"; then
output_sym "CONFIG_HAVE_GLIBC_STATX"
fi
if test "$has_cxx" = "yes"; then
output_sym "CONFIG_HAVE_CXX"
fi
if test "$has_ucontext" = "yes"; then
output_sym "CONFIG_HAVE_UCONTEXT"
fi
if test "$stringop_overflow" = "yes"; then
output_sym "CONFIG_HAVE_STRINGOP_OVERFLOW"
fi
if test "$array_bounds" = "yes"; then
output_sym "CONFIG_HAVE_ARRAY_BOUNDS"
fi
if test "$nvme_uring_cmd" = "yes"; then
output_sym "CONFIG_HAVE_NVME_URING"
fi
if test "$has_fanotify" = "yes"; then
output_sym "CONFIG_HAVE_FANOTIFY"
fi
echo "CC=$cc" >> $config_host_mak
print_config "CC" "$cc"
echo "CXX=$cxx" >> $config_host_mak
print_config "CXX" "$cxx"
# generate io_uring_version.h
# Reset MAKEFLAGS
MAKEFLAGS=
MAKE_PRINT_VARS="include Makefile.common\nprint-%: ; @echo \$(\$*)\n"
VERSION_MAJOR=$(env echo -e "$MAKE_PRINT_VARS" | make -s --no-print-directory -f - print-VERSION_MAJOR)
VERSION_MINOR=$(env echo -e "$MAKE_PRINT_VARS" | make -s --no-print-directory -f - print-VERSION_MINOR)
io_uring_version_h="src/include/liburing/io_uring_version.h"
cat > $io_uring_version_h << EOF
/* SPDX-License-Identifier: MIT */
#ifndef LIBURING_VERSION_H
#define LIBURING_VERSION_H
#define IO_URING_VERSION_MAJOR $VERSION_MAJOR
#define IO_URING_VERSION_MINOR $VERSION_MINOR
#endif
EOF
# generate compat.h
compat_h="src/include/liburing/compat.h"
cat > $compat_h << EOF
/* SPDX-License-Identifier: MIT */
#ifndef LIBURING_COMPAT_H
#define LIBURING_COMPAT_H
EOF
if test "$__kernel_rwf_t" != "yes"; then
cat >> $compat_h << EOF
typedef int __kernel_rwf_t;
EOF
fi
if test "$__kernel_timespec" != "yes"; then
cat >> $compat_h << EOF
#include
struct __kernel_timespec {
int64_t tv_sec;
long long tv_nsec;
};
/* is not available, so it can't be included */
#define UAPI_LINUX_IO_URING_H_SKIP_LINUX_TIME_TYPES_H 1
EOF
else
cat >> $compat_h << EOF
#include
/* is included above and not needed again */
#define UAPI_LINUX_IO_URING_H_SKIP_LINUX_TIME_TYPES_H 1
EOF
fi
if test "$open_how" != "yes"; then
cat >> $compat_h << EOF
#include
struct open_how {
uint64_t flags;
uint64_t mode;
uint64_t resolve;
};
EOF
else cat >> $compat_h << EOF
#include
EOF
fi
if [ "$glibc_statx" = "no" ] && [ "$statx" = "yes" ]; then
cat >> $compat_h << EOF
#include
EOF
fi
cat >> $compat_h << EOF
#endif
EOF
liburing-2.5/debian/ 0000775 0000000 0000000 00000000000 14521531436 0014421 5 ustar 00root root 0000000 0000000 liburing-2.5/debian/README.Debian 0000664 0000000 0000000 00000000354 14521531436 0016464 0 ustar 00root root 0000000 0000000 liburing for Debian
The newest Linux IO interface i.e. io_uring, need
userspace library to support it. This package
liburing is the library for io_uring.
-- Liu Changcheng Thu, 14 Nov 2019 21:35:39 +0800
liburing-2.5/debian/changelog 0000664 0000000 0000000 00000002153 14521531436 0016274 0 ustar 00root root 0000000 0000000 liburing (2.2-1) stable; urgency=low
* Update to 2.2
* Bump up so version to 2
* Drop liburing1-udeb
* Package using dh instead of using dh_* helpers manually
* Add linux header dependency to liburing-dev
* Bump up debhelper-compact level to 13
-- Kefu Chai Sun, 16 Oct 2022 16:30:48 +0800
liburing (0.7-1) stable; urgency=low
* Update to 0.7
* Fix library symlinks
-- Stefan Metzmacher Thu, 23 Jul 2020 00:23:00 +0200
liburing (0.4-2) stable; urgency=low
* Fix /usr/lib/*/liburing.so symlink to /lib/*/liburing.so.1.0.4
-- Stefan Metzmacher Fri, 07 Feb 2020 15:30:00 +0100
liburing (0.4-1) stable; urgency=low
* Package liburing-0.4 using a packaging layout similar to libaio1
-- Stefan Metzmacher Thu, 06 Feb 2020 11:30:00 +0100
liburing (0.2-1ubuntu1) stable; urgency=low
* Initial release.
* commit 4bce856d43ab1f9a64477aa5a8f9f02f53e64b74
* Author: Jens Axboe
* Date: Mon Nov 11 16:00:58 2019 -0700
-- Liu Changcheng Fri, 15 Nov 2019 00:06:46 +0800
liburing-2.5/debian/control 0000664 0000000 0000000 00000002310 14521531436 0016020 0 ustar 00root root 0000000 0000000 Source: liburing
Section: libs
Priority: optional
Maintainer: Liu Changcheng
Build-Depends:
debhelper-compat (= 13)
Standards-Version: 4.1.4
Homepage: https://git.kernel.dk/cgit/liburing/tree/README
Vcs-Git: https://git.kernel.dk/liburing
Vcs-Browser: https://git.kernel.dk/cgit/liburing/
Package: liburing2
Architecture: linux-any
Multi-Arch: same
Pre-Depends: ${misc:Pre-Depends}
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: userspace library for using io_uring
io_uring is kernel feature to improve development
The newese Linux IO interface, io_uring could improve
system performance a lot. liburing is the userpace
library to use io_uring feature.
.
This package contains the shared library.
Package: liburing-dev
Section: libdevel
Architecture: linux-any
Multi-Arch: same
Depends:
${misc:Depends},
liburing2 (= ${binary:Version}),
linux-libc-dev (>= 5.1)
Description: userspace library for using io_uring
io_uring is kernel feature to improve development
The newese Linux IO interface, io_uring could improve
system performance a lot. liburing is the userpace
library to use io_uring feature.
.
This package contains the static library and the header files.
liburing-2.5/debian/copyright 0000664 0000000 0000000 00000004175 14521531436 0016363 0 ustar 00root root 0000000 0000000 Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: liburing
Source: https://git.kernel.dk/cgit/liburing/
Files: *
Copyright: 2019 Jens Axboe
License: GPL-2+ / MIT
Files: debian/*
Copyright: 2019 Changcheng Liu
License: GPL-2+
License: GPL-2+
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see
.
On Debian systems, the complete text of the GNU General
Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
License: MIT
Copyright 2020 Jens Axboe
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
liburing-2.5/debian/liburing-dev.install 0000664 0000000 0000000 00000000103 14521531436 0020372 0 ustar 00root root 0000000 0000000 usr/include
usr/lib/*/lib*.so
usr/lib/*/lib*.a
usr/lib/*/pkgconfig
liburing-2.5/debian/liburing-dev.manpages 0000664 0000000 0000000 00000000240 14521531436 0020521 0 ustar 00root root 0000000 0000000 usr/share/man/man2/io_uring_*.2
usr/share/man/man3/io_uring_*.3
usr/share/man/man7/io_uring.7
usr/share/man/man3/IO_URING_*.3
usr/share/man/man3/__io_uring_*.3
liburing-2.5/debian/liburing2.install 0000664 0000000 0000000 00000000024 14521531436 0017702 0 ustar 00root root 0000000 0000000 usr/lib/*/lib*.so.*
liburing-2.5/debian/liburing2.symbols 0000664 0000000 0000000 00000005250 14521531436 0017732 0 ustar 00root root 0000000 0000000 liburing.so.2 liburing2 #MINVER# [47/1887]
LIBURING_2.0@LIBURING_2.0 0.7-1
LIBURING_2.1@LIBURING_2.1 0.7-1
LIBURING_2.2@LIBURING_2.2 0.7-1
LIBURING_2.3@LIBURING_2.3 0.7-1
__io_uring_get_cqe@LIBURING_2.0 0.7-1
__io_uring_sqring_wait@LIBURING_2.0 0.7-1
io_uring_enter2@LIBURING_2.3 0.7-1
io_uring_enter@LIBURING_2.3 0.7-1
io_uring_free_probe@LIBURING_2.0 0.7-1
io_uring_get_events@LIBURING_2.3 0.7-1
io_uring_get_probe@LIBURING_2.0 0.7-1
io_uring_get_probe_ring@LIBURING_2.0 0.7-1
io_uring_get_sqe@LIBURING_2.0 0.7-1
io_uring_mlock_size@LIBURING_2.1 0.7-1
io_uring_mlock_size_params@LIBURING_2.1 0.7-1
io_uring_peek_batch_cqe@LIBURING_2.0 0.7-1
io_uring_queue_exit@LIBURING_2.0 0.7-1
io_uring_queue_init@LIBURING_2.0 0.7-1
io_uring_queue_init_params@LIBURING_2.0 0.7-1
io_uring_queue_mmap@LIBURING_2.0 0.7-1
io_uring_register@LIBURING_2.3 0.7-1
io_uring_register_buf_ring@LIBURING_2.2 0.7-1
io_uring_register_buffers@LIBURING_2.0 0.7-1
io_uring_register_buffers_sparse@LIBURING_2.2 0.7-1
io_uring_register_buffers_tags@LIBURING_2.1 0.7-1
io_uring_register_buffers_update_tag@LIBURING_2.1 0.7-1
io_uring_register_eventfd@LIBURING_2.0 0.7-1
io_uring_register_eventfd_async@LIBURING_2.0 0.7-1
io_uring_register_file_alloc_range@LIBURING_2.3 0.7-1
io_uring_register_files@LIBURING_2.0 0.7-1
io_uring_register_files_sparse@LIBURING_2.2 0.7-1
io_uring_register_files_tags@LIBURING_2.1 0.7-1
io_uring_register_files_update@LIBURING_2.0 0.7-1
io_uring_register_files_update_tag@LIBURING_2.1 0.7-1
io_uring_register_iowq_aff@LIBURING_2.1 0.7-1
io_uring_register_iowq_max_workers@LIBURING_2.1 0.7-1
io_uring_register_personality@LIBURING_2.0 0.7-1
io_uring_register_probe@LIBURING_2.0 0.7-1
io_uring_register_ring_fd@LIBURING_2.2 0.7-1
io_uring_register_sync_cancel@LIBURING_2.3 0.7-1
io_uring_ring_dontfork@LIBURING_2.0 0.7-1
io_uring_setup@LIBURING_2.3 0.7-1
io_uring_submit@LIBURING_2.0 0.7-1
io_uring_submit_and_get_events@LIBURING_2.3 0.7-1
io_uring_submit_and_wait@LIBURING_2.0 0.7-1
io_uring_submit_and_wait_timeout@LIBURING_2.2 0.7-1
io_uring_unregister_buf_ring@LIBURING_2.2 0.7-1
io_uring_unregister_buffers@LIBURING_2.0 0.7-1
io_uring_unregister_eventfd@LIBURING_2.0 0.7-1
io_uring_unregister_files@LIBURING_2.0 0.7-1
io_uring_unregister_iowq_aff@LIBURING_2.1 0.7-1
io_uring_unregister_personality@LIBURING_2.0 0.7-1
io_uring_unregister_ring_fd@LIBURING_2.2 0.7-1
io_uring_wait_cqe_timeout@LIBURING_2.0 0.7-1
io_uring_wait_cqes@LIBURING_2.0 0.7-1
liburing-2.5/debian/patches/ 0000775 0000000 0000000 00000000000 14521531436 0016050 5 ustar 00root root 0000000 0000000 liburing-2.5/debian/patches/series 0000664 0000000 0000000 00000000101 14521531436 0017255 0 ustar 00root root 0000000 0000000 # You must remove unused comment lines for the released package.
liburing-2.5/debian/rules 0000775 0000000 0000000 00000001176 14521531436 0015506 0 ustar 00root root 0000000 0000000 #!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow
DEB_CFLAGS_MAINT_PREPEND = -Wall
DEB_BUILD_OPTIONS += nocheck
include /usr/share/dpkg/default.mk
include /usr/share/dpkg/buildtools.mk
%:
dh $@ --parallel
override_dh_auto_configure:
./configure \
--prefix=/usr \
--includedir=/usr/include \
--datadir=/usr/share \
--mandir=/usr/share/man \
--libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
--libdevdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
--cc=$(CC)
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
$(MAKE) runtests
endif
liburing-2.5/debian/source/ 0000775 0000000 0000000 00000000000 14521531436 0015721 5 ustar 00root root 0000000 0000000 liburing-2.5/debian/source/format 0000664 0000000 0000000 00000000014 14521531436 0017127 0 ustar 00root root 0000000 0000000 3.0 (quilt)
liburing-2.5/debian/source/local-options 0000664 0000000 0000000 00000000054 14521531436 0020426 0 ustar 00root root 0000000 0000000 #abort-on-upstream-changes
#unapply-patches
liburing-2.5/debian/source/options 0000664 0000000 0000000 00000000130 14521531436 0017331 0 ustar 00root root 0000000 0000000 extend-diff-ignore = "(^|/)(config\.log|config-host\.h|config-host\.mak|liburing\.pc)$"
liburing-2.5/debian/watch 0000664 0000000 0000000 00000000272 14521531436 0015453 0 ustar 00root root 0000000 0000000 # Site Directory Pattern Version Script
version=4
https://git.kernel.dk/cgit/liburing/ snapshot\/liburing-([\d\.]+)\.tar\.(?:gz|xz) debian uupdate
liburing-2.5/examples/ 0000775 0000000 0000000 00000000000 14521531436 0015015 5 ustar 00root root 0000000 0000000 liburing-2.5/examples/Makefile 0000664 0000000 0000000 00000001501 14521531436 0016452 0 ustar 00root root 0000000 0000000 CPPFLAGS ?=
override CPPFLAGS += -D_GNU_SOURCE -I../src/include/
CFLAGS ?= -g -O2 -Wall
LDFLAGS ?=
override LDFLAGS += -L../src/ -luring
include ../Makefile.quiet
ifneq ($(MAKECMDGOALS),clean)
include ../config-host.mak
endif
LDFLAGS ?=
override LDFLAGS += -L../src/ -luring -lpthread
example_srcs := \
io_uring-close-test.c \
io_uring-cp.c \
io_uring-test.c \
io_uring-udp.c \
link-cp.c \
poll-bench.c \
send-zerocopy.c \
rsrc-update-bench.c
all_targets :=
ifdef CONFIG_HAVE_UCONTEXT
example_srcs += ucontext-cp.c
endif
all_targets += ucontext-cp
example_targets := $(patsubst %.c,%,$(patsubst %.cc,%,$(example_srcs)))
all_targets += $(example_targets)
all: $(example_targets)
%: %.c ../src/liburing.a
$(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(LDFLAGS)
clean:
@rm -f $(all_targets)
.PHONY: all clean
liburing-2.5/examples/io_uring-close-test.c 0000664 0000000 0000000 00000004747 14521531436 0021070 0 ustar 00root root 0000000 0000000 /* SPDX-License-Identifier: MIT */
/*
* Simple app that demonstrates how to setup an io_uring interface, and use it
* via a registered ring fd, without leaving the original fd open.
*
* gcc -Wall -O2 -D_GNU_SOURCE -o io_uring-close-test io_uring-close-test.c -luring
*/
#include
#include
#include
#include
#include
#include
#include
#include "liburing.h"
#define QD 4
int main(int argc, char *argv[])
{
struct io_uring ring;
int i, fd, ret, pending, done;
struct io_uring_sqe *sqe;
struct io_uring_cqe *cqe;
struct iovec *iovecs;
struct stat sb;
ssize_t fsize;
off_t offset;
void *buf;
if (argc < 2) {
printf("%s: file\n", argv[0]);
return 1;
}
ret = io_uring_queue_init(QD, &ring, 0);
if (ret < 0) {
fprintf(stderr, "queue_init: %s\n", strerror(-ret));
return 1;
}
ret = io_uring_register_ring_fd(&ring);
if (ret < 0) {
fprintf(stderr, "register_ring_fd: %s\n", strerror(-ret));
return 1;
}
ret = io_uring_close_ring_fd(&ring);
if (ret < 0) {
fprintf(stderr, "close_ring_fd: %s\n", strerror(-ret));
return 1;
}
fd = open(argv[1], O_RDONLY);
if (fd < 0) {
perror("open");
return 1;
}
if (fstat(fd, &sb) < 0) {
perror("fstat");
return 1;
}
fsize = 0;
iovecs = calloc(QD, sizeof(struct iovec));
for (i = 0; i < QD; i++) {
if (posix_memalign(&buf, 4096, 4096))
return 1;
iovecs[i].iov_base = buf;
iovecs[i].iov_len = 4096;
fsize += 4096;
}
offset = 0;
i = 0;
do {
sqe = io_uring_get_sqe(&ring);
if (!sqe)
break;
io_uring_prep_readv(sqe, fd, &iovecs[i], 1, offset);
offset += iovecs[i].iov_len;
i++;
if (offset > sb.st_size)
break;
} while (1);
ret = io_uring_submit(&ring);
if (ret < 0) {
fprintf(stderr, "io_uring_submit: %s\n", strerror(-ret));
return 1;
} else if (ret != i) {
fprintf(stderr, "io_uring_submit submitted less %d\n", ret);
return 1;
}
done = 0;
pending = ret;
fsize = 0;
for (i = 0; i < pending; i++) {
ret = io_uring_wait_cqe(&ring, &cqe);
if (ret < 0) {
fprintf(stderr, "io_uring_wait_cqe: %s\n", strerror(-ret));
return 1;
}
done++;
ret = 0;
if (cqe->res != 4096 && cqe->res + fsize != sb.st_size) {
fprintf(stderr, "ret=%d, wanted 4096\n", cqe->res);
ret = 1;
}
fsize += cqe->res;
io_uring_cqe_seen(&ring, cqe);
if (ret)
break;
}
printf("Submitted=%d, completed=%d, bytes=%lu\n", pending, done,
(unsigned long) fsize);
close(fd);
io_uring_queue_exit(&ring);
return 0;
}
liburing-2.5/examples/io_uring-cp.c 0000664 0000000 0000000 00000012316 14521531436 0017377 0 ustar 00root root 0000000 0000000 /* SPDX-License-Identifier: MIT */
/*
* gcc -Wall -O2 -D_GNU_SOURCE -o io_uring-cp io_uring-cp.c -luring
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "liburing.h"
#define QD 64
#define BS (32*1024)
static int infd, outfd;
struct io_data {
int read;
off_t first_offset, offset;
size_t first_len;
struct iovec iov;
};
static int setup_context(unsigned entries, struct io_uring *ring)
{
int ret;
ret = io_uring_queue_init(entries, ring, 0);
if (ret < 0) {
fprintf(stderr, "queue_init: %s\n", strerror(-ret));
return -1;
}
return 0;
}
static int get_file_size(int fd, off_t *size)
{
struct stat st;
if (fstat(fd, &st) < 0)
return -1;
if (S_ISREG(st.st_mode)) {
*size = st.st_size;
return 0;
} else if (S_ISBLK(st.st_mode)) {
unsigned long long bytes;
if (ioctl(fd, BLKGETSIZE64, &bytes) != 0)
return -1;
*size = bytes;
return 0;
}
return -1;
}
static void queue_prepped(struct io_uring *ring, struct io_data *data)
{
struct io_uring_sqe *sqe;
sqe = io_uring_get_sqe(ring);
assert(sqe);
if (data->read)
io_uring_prep_readv(sqe, infd, &data->iov, 1, data->offset);
else
io_uring_prep_writev(sqe, outfd, &data->iov, 1, data->offset);
io_uring_sqe_set_data(sqe, data);
}
static int queue_read(struct io_uring *ring, off_t size, off_t offset)
{
struct io_uring_sqe *sqe;
struct io_data *data;
data = malloc(size + sizeof(*data));
if (!data)
return 1;
sqe = io_uring_get_sqe(ring);
if (!sqe) {
free(data);
return 1;
}
data->read = 1;
data->offset = data->first_offset = offset;
data->iov.iov_base = data + 1;
data->iov.iov_len = size;
data->first_len = size;
io_uring_prep_readv(sqe, infd, &data->iov, 1, offset);
io_uring_sqe_set_data(sqe, data);
return 0;
}
static void queue_write(struct io_uring *ring, struct io_data *data)
{
data->read = 0;
data->offset = data->first_offset;
data->iov.iov_base = data + 1;
data->iov.iov_len = data->first_len;
queue_prepped(ring, data);
io_uring_submit(ring);
}
static int copy_file(struct io_uring *ring, off_t insize)
{
unsigned long reads, writes;
struct io_uring_cqe *cqe;
off_t write_left, offset;
int ret;
write_left = insize;
writes = reads = offset = 0;
while (insize || write_left) {
unsigned long had_reads;
int got_comp;
/*
* Queue up as many reads as we can
*/
had_reads = reads;
while (insize) {
off_t this_size = insize;
if (reads + writes >= QD)
break;
if (this_size > BS)
this_size = BS;
else if (!this_size)
break;
if (queue_read(ring, this_size, offset))
break;
insize -= this_size;
offset += this_size;
reads++;
}
if (had_reads != reads) {
ret = io_uring_submit(ring);
if (ret < 0) {
fprintf(stderr, "io_uring_submit: %s\n", strerror(-ret));
break;
}
}
/*
* Queue is full at this point. Find at least one completion.
*/
got_comp = 0;
while (write_left) {
struct io_data *data;
if (!got_comp) {
ret = io_uring_wait_cqe(ring, &cqe);
got_comp = 1;
} else {
ret = io_uring_peek_cqe(ring, &cqe);
if (ret == -EAGAIN) {
cqe = NULL;
ret = 0;
}
}
if (ret < 0) {
fprintf(stderr, "io_uring_peek_cqe: %s\n",
strerror(-ret));
return 1;
}
if (!cqe)
break;
data = io_uring_cqe_get_data(cqe);
if (cqe->res < 0) {
if (cqe->res == -EAGAIN) {
queue_prepped(ring, data);
io_uring_submit(ring);
io_uring_cqe_seen(ring, cqe);
continue;
}
fprintf(stderr, "cqe failed: %s\n",
strerror(-cqe->res));
return 1;
} else if ((size_t)cqe->res != data->iov.iov_len) {
/* Short read/write, adjust and requeue */
data->iov.iov_base += cqe->res;
data->iov.iov_len -= cqe->res;
data->offset += cqe->res;
queue_prepped(ring, data);
io_uring_submit(ring);
io_uring_cqe_seen(ring, cqe);
continue;
}
/*
* All done. if write, nothing else to do. if read,
* queue up corresponding write.
*/
if (data->read) {
queue_write(ring, data);
write_left -= data->first_len;
reads--;
writes++;
} else {
free(data);
writes--;
}
io_uring_cqe_seen(ring, cqe);
}
}
/* wait out pending writes */
while (writes) {
struct io_data *data;
ret = io_uring_wait_cqe(ring, &cqe);
if (ret) {
fprintf(stderr, "wait_cqe=%d\n", ret);
return 1;
}
if (cqe->res < 0) {
fprintf(stderr, "write res=%d\n", cqe->res);
return 1;
}
data = io_uring_cqe_get_data(cqe);
free(data);
writes--;
io_uring_cqe_seen(ring, cqe);
}
return 0;
}
int main(int argc, char *argv[])
{
struct io_uring ring;
off_t insize;
int ret;
if (argc < 3) {
printf("%s: infile outfile\n", argv[0]);
return 1;
}
infd = open(argv[1], O_RDONLY);
if (infd < 0) {
perror("open infile");
return 1;
}
outfd = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (outfd < 0) {
perror("open outfile");
return 1;
}
if (setup_context(QD, &ring))
return 1;
if (get_file_size(infd, &insize))
return 1;
ret = copy_file(&ring, insize);
close(infd);
close(outfd);
io_uring_queue_exit(&ring);
return ret;
}
liburing-2.5/examples/io_uring-test.c 0000664 0000000 0000000 00000004321 14521531436 0017751 0 ustar 00root root 0000000 0000000 /* SPDX-License-Identifier: MIT */
/*
* Simple app that demonstrates how to setup an io_uring interface,
* submit and complete IO against it, and then tear it down.
*
* gcc -Wall -O2 -D_GNU_SOURCE -o io_uring-test io_uring-test.c -luring
*/
#include
#include
#include
#include
#include
#include
#include
#include "liburing.h"
#define QD 4
int main(int argc, char *argv[])
{
struct io_uring ring;
int i, fd, ret, pending, done;
struct io_uring_sqe *sqe;
struct io_uring_cqe *cqe;
struct iovec *iovecs;
struct stat sb;
ssize_t fsize;
off_t offset;
void *buf;
if (argc < 2) {
printf("%s: file\n", argv[0]);
return 1;
}
ret = io_uring_queue_init(QD, &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 (fstat(fd, &sb) < 0) {
perror("fstat");
return 1;
}
fsize = 0;
iovecs = calloc(QD, sizeof(struct iovec));
for (i = 0; i < QD; i++) {
if (posix_memalign(&buf, 4096, 4096))
return 1;
iovecs[i].iov_base = buf;
iovecs[i].iov_len = 4096;
fsize += 4096;
}
offset = 0;
i = 0;
do {
sqe = io_uring_get_sqe(&ring);
if (!sqe)
break;
io_uring_prep_readv(sqe, fd, &iovecs[i], 1, offset);
offset += iovecs[i].iov_len;
i++;
if (offset >= sb.st_size)
break;
} while (1);
ret = io_uring_submit(&ring);
if (ret < 0) {
fprintf(stderr, "io_uring_submit: %s\n", strerror(-ret));
return 1;
} else if (ret != i) {
fprintf(stderr, "io_uring_submit submitted less %d\n", ret);
return 1;
}
done = 0;
pending = ret;
fsize = 0;
for (i = 0; i < pending; i++) {
ret = io_uring_wait_cqe(&ring, &cqe);
if (ret < 0) {
fprintf(stderr, "io_uring_wait_cqe: %s\n", strerror(-ret));
return 1;
}
done++;
ret = 0;
if (cqe->res != 4096 && cqe->res + fsize != sb.st_size) {
fprintf(stderr, "ret=%d, wanted 4096\n", cqe->res);
ret = 1;
}
fsize += cqe->res;
io_uring_cqe_seen(&ring, cqe);
if (ret)
break;
}
printf("Submitted=%d, completed=%d, bytes=%lu\n", pending, done,
(unsigned long) fsize);
close(fd);
io_uring_queue_exit(&ring);
return 0;
}
liburing-2.5/examples/io_uring-udp.c 0000664 0000000 0000000 00000021167 14521531436 0017571 0 ustar 00root root 0000000 0000000 /* SPDX-License-Identifier: MIT */
#include
#include
#include
#include
#include
#include
#include
#include
#include "liburing.h"
#define QD 64
#define BUF_SHIFT 12 /* 4k */
#define CQES (QD * 16)
#define BUFFERS CQES
#define CONTROLLEN 0
struct sendmsg_ctx {
struct msghdr msg;
struct iovec iov;
};
struct ctx {
struct io_uring ring;
struct io_uring_buf_ring *buf_ring;
unsigned char *buffer_base;
struct msghdr msg;
int buf_shift;
int af;
bool verbose;
struct sendmsg_ctx send[BUFFERS];
size_t buf_ring_size;
};
static size_t buffer_size(struct ctx *ctx)
{
return 1U << ctx->buf_shift;
}
static unsigned char *get_buffer(struct ctx *ctx, int idx)
{
return ctx->buffer_base + (idx << ctx->buf_shift);
}
static int setup_buffer_pool(struct ctx *ctx)
{
int ret, i;
void *mapped;
struct io_uring_buf_reg reg = { .ring_addr = 0,
.ring_entries = BUFFERS,
.bgid = 0 };
ctx->buf_ring_size = (sizeof(struct io_uring_buf) + buffer_size(ctx)) * BUFFERS;
mapped = mmap(NULL, ctx->buf_ring_size, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
if (mapped == MAP_FAILED) {
fprintf(stderr, "buf_ring mmap: %s\n", strerror(errno));
return -1;
}
ctx->buf_ring = (struct io_uring_buf_ring *)mapped;
io_uring_buf_ring_init(ctx->buf_ring);
reg = (struct io_uring_buf_reg) {
.ring_addr = (unsigned long)ctx->buf_ring,
.ring_entries = BUFFERS,
.bgid = 0
};
ctx->buffer_base = (unsigned char *)ctx->buf_ring +
sizeof(struct io_uring_buf) * BUFFERS;
ret = io_uring_register_buf_ring(&ctx->ring, ®, 0);
if (ret) {
fprintf(stderr, "buf_ring init failed: %s\n"
"NB This requires a kernel version >= 6.0\n",
strerror(-ret));
return ret;
}
for (i = 0; i < BUFFERS; i++) {
io_uring_buf_ring_add(ctx->buf_ring, get_buffer(ctx, i), buffer_size(ctx), i,
io_uring_buf_ring_mask(BUFFERS), i);
}
io_uring_buf_ring_advance(ctx->buf_ring, BUFFERS);
return 0;
}
static int setup_context(struct ctx *ctx)
{
struct io_uring_params params;
int ret;
memset(¶ms, 0, sizeof(params));
params.cq_entries = QD * 8;
params.flags = IORING_SETUP_SUBMIT_ALL | IORING_SETUP_COOP_TASKRUN |
IORING_SETUP_CQSIZE;
ret = io_uring_queue_init_params(QD, &ctx->ring, ¶ms);
if (ret < 0) {
fprintf(stderr, "queue_init failed: %s\n"
"NB: This requires a kernel version >= 6.0\n",
strerror(-ret));
return ret;
}
ret = setup_buffer_pool(ctx);
if (ret)
io_uring_queue_exit(&ctx->ring);
memset(&ctx->msg, 0, sizeof(ctx->msg));
ctx->msg.msg_namelen = sizeof(struct sockaddr_storage);
ctx->msg.msg_controllen = CONTROLLEN;
return ret;
}
static int setup_sock(int af, int port)
{
int ret;
int fd;
uint16_t nport = port <= 0 ? 0 : htons(port);
fd = socket(af, SOCK_DGRAM, 0);
if (fd < 0) {
fprintf(stderr, "sock_init: %s\n", strerror(errno));
return -1;
}
if (af == AF_INET6) {
struct sockaddr_in6 addr6 = {
.sin6_family = af,
.sin6_port = nport,
.sin6_addr = IN6ADDR_ANY_INIT
};
ret = bind(fd, (struct sockaddr *) &addr6, sizeof(addr6));
} else {
struct sockaddr_in addr = {
.sin_family = af,
.sin_port = nport,
.sin_addr = { INADDR_ANY }
};
ret = bind(fd, (struct sockaddr *) &addr, sizeof(addr));
}
if (ret) {
fprintf(stderr, "sock_bind: %s\n", strerror(errno));
close(fd);
return -1;
}
if (port <= 0) {
int port;
struct sockaddr_storage s;
socklen_t sz = sizeof(s);
if (getsockname(fd, (struct sockaddr *)&s, &sz)) {
fprintf(stderr, "getsockname failed\n");
close(fd);
return -1;
}
port = ntohs(((struct sockaddr_in *)&s)->sin_port);
fprintf(stderr, "port bound to %d\n", port);
}
return fd;
}
static void cleanup_context(struct ctx *ctx)
{
munmap(ctx->buf_ring, ctx->buf_ring_size);
io_uring_queue_exit(&ctx->ring);
}
static bool get_sqe(struct ctx *ctx, struct io_uring_sqe **sqe)
{
*sqe = io_uring_get_sqe(&ctx->ring);
if (!*sqe) {
io_uring_submit(&ctx->ring);
*sqe = io_uring_get_sqe(&ctx->ring);
}
if (!*sqe) {
fprintf(stderr, "cannot get sqe\n");
return true;
}
return false;
}
static int add_recv(struct ctx *ctx, int idx)
{
struct io_uring_sqe *sqe;
if (get_sqe(ctx, &sqe))
return -1;
io_uring_prep_recvmsg_multishot(sqe, idx, &ctx->msg, MSG_TRUNC);
sqe->flags |= IOSQE_FIXED_FILE;
sqe->flags |= IOSQE_BUFFER_SELECT;
sqe->buf_group = 0;
io_uring_sqe_set_data64(sqe, BUFFERS + 1);
return 0;
}
static void recycle_buffer(struct ctx *ctx, int idx)
{
io_uring_buf_ring_add(ctx->buf_ring, get_buffer(ctx, idx), buffer_size(ctx), idx,
io_uring_buf_ring_mask(BUFFERS), 0);
io_uring_buf_ring_advance(ctx->buf_ring, 1);
}
static int process_cqe_send(struct ctx *ctx, struct io_uring_cqe *cqe)
{
int idx = cqe->user_data;
if (cqe->res < 0)
fprintf(stderr, "bad send %s\n", strerror(-cqe->res));
recycle_buffer(ctx, idx);
return 0;
}
static int process_cqe_recv(struct ctx *ctx, struct io_uring_cqe *cqe,
int fdidx)
{
int ret, idx;
struct io_uring_recvmsg_out *o;
struct io_uring_sqe *sqe;
if (!(cqe->flags & IORING_CQE_F_MORE)) {
ret = add_recv(ctx, fdidx);
if (ret)
return ret;
}
if (cqe->res == -ENOBUFS)
return 0;
if (!(cqe->flags & IORING_CQE_F_BUFFER) || cqe->res < 0) {
fprintf(stderr, "recv cqe bad res %d\n", cqe->res);
if (cqe->res == -EFAULT || cqe->res == -EINVAL)
fprintf(stderr,
"NB: This requires a kernel version >= 6.0\n");
return -1;
}
idx = cqe->flags >> 16;
o = io_uring_recvmsg_validate(get_buffer(ctx, cqe->flags >> 16),
cqe->res, &ctx->msg);
if (!o) {
fprintf(stderr, "bad recvmsg\n");
return -1;
}
if (o->namelen > ctx->msg.msg_namelen) {
fprintf(stderr, "truncated name\n");
recycle_buffer(ctx, idx);
return 0;
}
if (o->flags & MSG_TRUNC) {
unsigned int r;
r = io_uring_recvmsg_payload_length(o, cqe->res, &ctx->msg);
fprintf(stderr, "truncated msg need %u received %u\n",
o->payloadlen, r);
recycle_buffer(ctx, idx);
return 0;
}
if (ctx->verbose) {
struct sockaddr_in *addr = io_uring_recvmsg_name(o);
struct sockaddr_in6 *addr6 = (void *)addr;
char buff[INET6_ADDRSTRLEN + 1];
const char *name;
void *paddr;
if (ctx->af == AF_INET6)
paddr = &addr6->sin6_addr;
else
paddr = &addr->sin_addr;
name = inet_ntop(ctx->af, paddr, buff, sizeof(buff));
if (!name)
name = "";
fprintf(stderr, "received %u bytes %d from [%s]:%d\n",
io_uring_recvmsg_payload_length(o, cqe->res, &ctx->msg),
o->namelen, name, (int)ntohs(addr->sin_port));
}
if (get_sqe(ctx, &sqe))
return -1;
ctx->send[idx].iov = (struct iovec) {
.iov_base = io_uring_recvmsg_payload(o, &ctx->msg),
.iov_len =
io_uring_recvmsg_payload_length(o, cqe->res, &ctx->msg)
};
ctx->send[idx].msg = (struct msghdr) {
.msg_namelen = o->namelen,
.msg_name = io_uring_recvmsg_name(o),
.msg_control = NULL,
.msg_controllen = 0,
.msg_iov = &ctx->send[idx].iov,
.msg_iovlen = 1
};
io_uring_prep_sendmsg(sqe, fdidx, &ctx->send[idx].msg, 0);
io_uring_sqe_set_data64(sqe, idx);
sqe->flags |= IOSQE_FIXED_FILE;
return 0;
}
static int process_cqe(struct ctx *ctx, struct io_uring_cqe *cqe, int fdidx)
{
if (cqe->user_data < BUFFERS)
return process_cqe_send(ctx, cqe);
else
return process_cqe_recv(ctx, cqe, fdidx);
}
int main(int argc, char *argv[])
{
struct ctx ctx;
int ret;
int port = -1;
int sockfd;
int opt;
struct io_uring_cqe *cqes[CQES];
unsigned int count, i;
memset(&ctx, 0, sizeof(ctx));
ctx.verbose = false;
ctx.af = AF_INET;
ctx.buf_shift = BUF_SHIFT;
while ((opt = getopt(argc, argv, "6vp:b:")) != -1) {
switch (opt) {
case '6':
ctx.af = AF_INET6;
break;
case 'p':
port = atoi(optarg);
break;
case 'b':
ctx.buf_shift = atoi(optarg);
break;
case 'v':
ctx.verbose = true;
break;
default:
fprintf(stderr, "Usage: %s [-p port] "
"[-b log2(BufferSize)] [-6] [-v]\n",
argv[0]);
exit(-1);
}
}
sockfd = setup_sock(ctx.af, port);
if (sockfd < 0)
return 1;
if (setup_context(&ctx)) {
close(sockfd);
return 1;
}
ret = io_uring_register_files(&ctx.ring, &sockfd, 1);
if (ret) {
fprintf(stderr, "register files: %s\n", strerror(-ret));
return -1;
}
ret = add_recv(&ctx, 0);
if (ret)
return 1;
while (true) {
ret = io_uring_submit_and_wait(&ctx.ring, 1);
if (ret == -EINTR)
continue;
if (ret < 0) {
fprintf(stderr, "submit and wait failed %d\n", ret);
break;
}
count = io_uring_peek_batch_cqe(&ctx.ring, &cqes[0], CQES);
for (i = 0; i < count; i++) {
ret = process_cqe(&ctx, cqes[i], 0);
if (ret)
goto cleanup;
}
io_uring_cq_advance(&ctx.ring, count);
}
cleanup:
cleanup_context(&ctx);
close(sockfd);
return ret;
}
liburing-2.5/examples/link-cp.c 0000664 0000000 0000000 00000006732 14521531436 0016526 0 ustar 00root root 0000000 0000000 /* SPDX-License-Identifier: MIT */
/*
* Very basic proof-of-concept for doing a copy with linked SQEs. Needs a
* bit of error handling and short read love.
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "liburing.h"
#define QD 64
#define BS (32*1024)
struct io_data {
size_t offset;
int index;
struct iovec iov;
};
static int infd, outfd;
static int inflight;
static int setup_context(unsigned entries, struct io_uring *ring)
{
int ret;
ret = io_uring_queue_init(entries, ring, 0);
if (ret < 0) {
fprintf(stderr, "queue_init: %s\n", strerror(-ret));
return -1;
}
return 0;
}
static int get_file_size(int fd, off_t *size)
{
struct stat st;
if (fstat(fd, &st) < 0)
return -1;
if (S_ISREG(st.st_mode)) {
*size = st.st_size;
return 0;
} else if (S_ISBLK(st.st_mode)) {
unsigned long long bytes;
if (ioctl(fd, BLKGETSIZE64, &bytes) != 0)
return -1;
*size = bytes;
return 0;
}
return -1;
}
static void queue_rw_pair(struct io_uring *ring, off_t size, off_t offset)
{
struct io_uring_sqe *sqe;
struct io_data *data;
void *ptr;
ptr = malloc(size + sizeof(*data));
data = ptr + size;
data->index = 0;
data->offset = offset;
data->iov.iov_base = ptr;
data->iov.iov_len = size;
sqe = io_uring_get_sqe(ring);
io_uring_prep_readv(sqe, infd, &data->iov, 1, offset);
sqe->flags |= IOSQE_IO_LINK;
io_uring_sqe_set_data(sqe, data);
sqe = io_uring_get_sqe(ring);
io_uring_prep_writev(sqe, outfd, &data->iov, 1, offset);
io_uring_sqe_set_data(sqe, data);
}
static int handle_cqe(struct io_uring *ring, struct io_uring_cqe *cqe)
{
struct io_data *data = io_uring_cqe_get_data(cqe);
int ret = 0;
data->index++;
if (cqe->res < 0) {
if (cqe->res == -ECANCELED) {
queue_rw_pair(ring, data->iov.iov_len, data->offset);
inflight += 2;
} else {
printf("cqe error: %s\n", strerror(-cqe->res));
ret = 1;
}
}
if (data->index == 2) {
void *ptr = (void *) data - data->iov.iov_len;
free(ptr);
}
io_uring_cqe_seen(ring, cqe);
return ret;
}
static int copy_file(struct io_uring *ring, off_t insize)
{
struct io_uring_cqe *cqe;
off_t this_size;
off_t offset;
offset = 0;
while (insize) {
int has_inflight = inflight;
int depth;
while (insize && inflight < QD) {
this_size = BS;
if (this_size > insize)
this_size = insize;
queue_rw_pair(ring, this_size, offset);
offset += this_size;
insize -= this_size;
inflight += 2;
}
if (has_inflight != inflight)
io_uring_submit(ring);
if (insize)
depth = QD;
else
depth = 1;
while (inflight >= depth) {
int ret;
ret = io_uring_wait_cqe(ring, &cqe);
if (ret < 0) {
printf("wait cqe: %s\n", strerror(-ret));
return 1;
}
if (handle_cqe(ring, cqe))
return 1;
inflight--;
}
}
return 0;
}
int main(int argc, char *argv[])
{
struct io_uring ring;
off_t insize;
int ret;
if (argc < 3) {
printf("%s: infile outfile\n", argv[0]);
return 1;
}
infd = open(argv[1], O_RDONLY);
if (infd < 0) {
perror("open infile");
return 1;
}
outfd = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (outfd < 0) {
perror("open outfile");
return 1;
}
if (setup_context(QD, &ring))
return 1;
if (get_file_size(infd, &insize))
return 1;
ret = copy_file(&ring, insize);
close(infd);
close(outfd);
io_uring_queue_exit(&ring);
return ret;
}
liburing-2.5/examples/poll-bench.c 0000664 0000000 0000000 00000004121 14521531436 0017202 0 ustar 00root root 0000000 0000000 /* SPDX-License-Identifier: MIT */
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "liburing.h"
static char buf[4096];
static unsigned long runtime_ms = 10000;
static unsigned long gettimeofday_ms(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
}
int main(void)
{
unsigned long tstop;
unsigned long nr_reqs = 0;
struct io_uring_cqe *cqe;
struct io_uring_sqe *sqe;
struct io_uring ring;
int pipe1[2];
int ret, i, qd = 32;
if (pipe(pipe1) != 0) {
perror("pipe");
return 1;
}
ret = io_uring_queue_init(1024, &ring, IORING_SETUP_SINGLE_ISSUER);
if (ret == -EINVAL) {
fprintf(stderr, "can't single\n");
ret = io_uring_queue_init(1024, &ring, 0);
}
if (ret) {
fprintf(stderr, "child: ring setup failed: %d\n", ret);
return 1;
}
ret = io_uring_register_files(&ring, pipe1, 2);
if (ret < 0) {
fprintf(stderr, "io_uring_register_files failed\n");
return 1;
}
ret = io_uring_register_ring_fd(&ring);
if (ret < 0) {
fprintf(stderr, "io_uring_register_ring_fd failed\n");
return 1;
}
tstop = gettimeofday_ms() + runtime_ms;
do {
for (i = 0; i < qd; i++) {
sqe = io_uring_get_sqe(&ring);
io_uring_prep_poll_add(sqe, 0, POLLIN);
sqe->flags |= IOSQE_FIXED_FILE;
sqe->user_data = 1;
}
ret = io_uring_submit(&ring);
if (ret != qd) {
fprintf(stderr, "child: sqe submit failed: %d\n", ret);
return 1;
}
ret = write(pipe1[1], buf, 1);
if (ret != 1) {
fprintf(stderr, "write failed %i\n", errno);
return 1;
}
ret = read(pipe1[0], buf, 1);
if (ret != 1) {
fprintf(stderr, "read failed %i\n", errno);
return 1;
}
for (i = 0; i < qd; i++) {
ret = io_uring_wait_cqe(&ring, &cqe);
if (ret < 0) {
fprintf(stderr, "child: wait completion %d\n", ret);
break;
}
io_uring_cqe_seen(&ring, cqe);
nr_reqs++;
}
} while (gettimeofday_ms() < tstop);
fprintf(stderr, "requests/s: %lu\n", nr_reqs * 1000UL / runtime_ms);
return 0;
}
liburing-2.5/examples/rsrc-update-bench.c 0000664 0000000 0000000 00000004140 14521531436 0020466 0 ustar 00root root 0000000 0000000 /* SPDX-License-Identifier: MIT */
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "liburing.h"
static unsigned long runtime_ms = 10000;
static unsigned long gettimeofday_ms(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
}
int main(void)
{
unsigned long tstop;
unsigned long nr_reqs = 0;
struct io_uring_cqe *cqe;
struct io_uring_sqe *sqe;
struct io_uring ring;
int pipe1[2];
int ret, i, qd = 32;
int table_size = 128;
if (pipe(pipe1) != 0) {
perror("pipe");
return 1;
}
ret = io_uring_queue_init(1024, &ring, IORING_SETUP_SINGLE_ISSUER |
IORING_SETUP_DEFER_TASKRUN);
if (ret) {
fprintf(stderr, "io_uring_queue_init failed: %d\n", ret);
return 1;
}
ret = io_uring_register_ring_fd(&ring);
if (ret < 0) {
fprintf(stderr, "io_uring_register_ring_fd failed\n");
return 1;
}
ret = io_uring_register_files_sparse(&ring, table_size);
if (ret < 0) {
fprintf(stderr, "io_uring_register_files_sparse failed\n");
return 1;
}
for (i = 0; i < table_size; i++) {
ret = io_uring_register_files_update(&ring, i, pipe1, 1);
if (ret < 0) {
fprintf(stderr, "io_uring_register_files_update failed\n");
return 1;
}
}
srand(time(NULL));
tstop = gettimeofday_ms() + runtime_ms;
do {
int off = rand();
for (i = 0; i < qd; i++) {
sqe = io_uring_get_sqe(&ring);
int roff = (off + i) % table_size;
io_uring_prep_files_update(sqe, pipe1, 1, roff);
}
ret = io_uring_submit(&ring);
if (ret != qd) {
fprintf(stderr, "child: sqe submit failed: %d\n", ret);
return 1;
}
for (i = 0; i < qd; i++) {
ret = io_uring_wait_cqe(&ring, &cqe);
if (ret < 0) {
fprintf(stderr, "child: wait completion %d\n", ret);
break;
}
io_uring_cqe_seen(&ring, cqe);
nr_reqs++;
}
} while (gettimeofday_ms() < tstop);
fprintf(stderr, "max updates/s: %lu\n", nr_reqs * 1000UL / runtime_ms);
io_uring_queue_exit(&ring);
close(pipe1[0]);
close(pipe1[1]);
return 0;
}
liburing-2.5/examples/send-zerocopy.c 0000664 0000000 0000000 00000032204 14521531436 0017763 0 ustar 00root root 0000000 0000000 /* SPDX-License-Identifier: MIT */
/* based on linux-kernel/tools/testing/selftests/net/msg_zerocopy.c */
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "liburing.h"
#define ZC_TAG 0xfffffffULL
#define MAX_SUBMIT_NR 512
#define MAX_THREADS 100
struct thread_data {
pthread_t thread;
void *ret;
int idx;
unsigned long long packets;
unsigned long long bytes;
struct sockaddr_storage dst_addr;
int fd;
};
static bool cfg_reg_ringfd = true;
static bool cfg_fixed_files = 1;
static bool cfg_zc = 1;
static int cfg_nr_reqs = 8;
static bool cfg_fixed_buf = 1;
static bool cfg_hugetlb = 0;
static bool cfg_defer_taskrun = 0;
static int cfg_cpu = -1;
static bool cfg_rx = 0;
static unsigned cfg_nr_threads = 1;
static int cfg_family = PF_UNSPEC;
static int cfg_type = 0;
static int cfg_payload_len;
static int cfg_port = 8000;
static int cfg_runtime_ms = 4200;
static socklen_t cfg_alen;
static char *str_addr = NULL;
static char payload_buf[IP_MAXPACKET] __attribute__((aligned(4096)));
static char *payload;
static struct thread_data threads[MAX_THREADS];
static pthread_barrier_t barrier;
/*
* Implementation of error(3), prints an error message and exits.
*/
static void t_error(int status, int errnum, const char *format, ...)
{
va_list args;
va_start(args, format);
vfprintf(stderr, format, args);
if (errnum)
fprintf(stderr, ": %s", strerror(errnum));
fprintf(stderr, "\n");
va_end(args);
exit(status);
}
static void set_cpu_affinity(void)
{
cpu_set_t mask;
if (cfg_cpu == -1)
return;
CPU_ZERO(&mask);
CPU_SET(cfg_cpu, &mask);
if (sched_setaffinity(0, sizeof(mask), &mask))
t_error(1, errno, "unable to pin cpu\n");
}
static void set_iowq_affinity(struct io_uring *ring)
{
cpu_set_t mask;
int ret;
if (cfg_cpu == -1)
return;
ret = io_uring_register_iowq_aff(ring, 1, &mask);
if (ret)
t_error(1, ret, "unabled to set io-wq affinity\n");
}
static unsigned long gettimeofday_ms(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
}
static void do_setsockopt(int fd, int level, int optname, int val)
{
if (setsockopt(fd, level, optname, &val, sizeof(val)))
t_error(1, errno, "setsockopt %d.%d: %d", level, optname, val);
}
static void setup_sockaddr(int domain, const char *str_addr,
struct sockaddr_storage *sockaddr)
{
struct sockaddr_in6 *addr6 = (void *) sockaddr;
struct sockaddr_in *addr4 = (void *) sockaddr;
int port = cfg_port;
switch (domain) {
case PF_INET:
memset(addr4, 0, sizeof(*addr4));
addr4->sin_family = AF_INET;
addr4->sin_port = htons(port);
if (str_addr &&
inet_pton(AF_INET, str_addr, &(addr4->sin_addr)) != 1)
t_error(1, 0, "ipv4 parse error: %s", str_addr);
break;
case PF_INET6:
memset(addr6, 0, sizeof(*addr6));
addr6->sin6_family = AF_INET6;
addr6->sin6_port = htons(port);
if (str_addr &&
inet_pton(AF_INET6, str_addr, &(addr6->sin6_addr)) != 1)
t_error(1, 0, "ipv6 parse error: %s", str_addr);
break;
default:
t_error(1, 0, "illegal domain");
}
}
static int do_poll(int fd, int events)
{
struct pollfd pfd;
int ret;
pfd.events = events;
pfd.revents = 0;
pfd.fd = fd;
ret = poll(&pfd, 1, -1);
if (ret == -1)
t_error(1, errno, "poll");
return ret && (pfd.revents & events);
}
/* Flush all outstanding bytes for the tcp receive queue */
static int do_flush_tcp(struct thread_data *td, int fd)
{
int ret;
/* MSG_TRUNC flushes up to len bytes */
ret = recv(fd, NULL, 1 << 21, MSG_TRUNC | MSG_DONTWAIT);
if (ret == -1 && errno == EAGAIN)
return 0;
if (ret == -1)
t_error(1, errno, "flush");
if (!ret)
return 1;
td->packets++;
td->bytes += ret;
return 0;
}
/* Flush all outstanding datagrams. Verify first few bytes of each. */
static int do_flush_datagram(struct thread_data *td, int fd)
{
long ret, off = 0;
char buf[64];
/* MSG_TRUNC will return full datagram length */
ret = recv(fd, buf, sizeof(buf), MSG_DONTWAIT | MSG_TRUNC);
if (ret == -1 && errno == EAGAIN)
return 0;
if (ret == -1)
t_error(1, errno, "recv");
if (ret != cfg_payload_len)
t_error(1, 0, "recv: ret=%u != %u", ret, cfg_payload_len);
if ((unsigned long) ret > sizeof(buf) - off)
ret = sizeof(buf) - off;
if (memcmp(buf + off, payload, ret))
t_error(1, 0, "recv: data mismatch");
td->packets++;
td->bytes += cfg_payload_len;
return 0;
}
static void do_setup_rx(int domain, int type, int protocol)
{
struct sockaddr_storage addr = {};
struct thread_data *td;
int listen_fd, fd;
unsigned int i;
fd = socket(domain, type, protocol);
if (fd == -1)
t_error(1, errno, "socket r");
do_setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, 1);
setup_sockaddr(cfg_family, str_addr, &addr);
if (bind(fd, (void *)&addr, cfg_alen))
t_error(1, errno, "bind");
if (type != SOCK_STREAM) {
if (cfg_nr_threads != 1)
t_error(1, 0, "udp rx cant multithread");
threads[0].fd = fd;
return;
}
listen_fd = fd;
if (listen(listen_fd, cfg_nr_threads))
t_error(1, errno, "listen");
for (i = 0; i < cfg_nr_threads; i++) {
td = &threads[i];
fd = accept(listen_fd, NULL, NULL);
if (fd == -1)
t_error(1, errno, "accept");
td->fd = fd;
}
if (close(listen_fd))
t_error(1, errno, "close listen sock");
}
static void *do_rx(void *arg)
{
struct thread_data *td = arg;
const int cfg_receiver_wait_ms = 400;
uint64_t tstop;
int ret, fd = td->fd;
tstop = gettimeofday_ms() + cfg_runtime_ms + cfg_receiver_wait_ms;
do {
if (cfg_type == SOCK_STREAM)
ret = do_flush_tcp(td, fd);
else
ret = do_flush_datagram(td, fd);
if (ret)
break;
do_poll(fd, POLLIN);
} while (gettimeofday_ms() < tstop);
if (close(fd))
t_error(1, errno, "close");
pthread_exit(&td->ret);
return NULL;
}
static inline struct io_uring_cqe *wait_cqe_fast(struct io_uring *ring)
{
struct io_uring_cqe *cqe;
unsigned head;
int ret;
io_uring_for_each_cqe(ring, head, cqe)
return cqe;
ret = io_uring_wait_cqe(ring, &cqe);
if (ret)
t_error(1, ret, "wait cqe");
return cqe;
}
static void do_tx(struct thread_data *td, int domain, int type, int protocol)
{
const int notif_slack = 128;
struct io_uring ring;
struct iovec iov;
uint64_t tstop;
int i, fd, ret;
int compl_cqes = 0;
int ring_flags = IORING_SETUP_COOP_TASKRUN | IORING_SETUP_SINGLE_ISSUER;
if (cfg_defer_taskrun)
ring_flags |= IORING_SETUP_DEFER_TASKRUN;
fd = socket(domain, type, protocol);
if (fd == -1)
t_error(1, errno, "socket t");
if (connect(fd, (void *)&td->dst_addr, cfg_alen))
t_error(1, errno, "connect, idx %i", td->idx);
ret = io_uring_queue_init(512, &ring, ring_flags);
if (ret)
t_error(1, ret, "io_uring: queue init");
set_cpu_affinity();
set_iowq_affinity(&ring);
if (cfg_fixed_files) {
ret = io_uring_register_files(&ring, &fd, 1);
if (ret < 0)
t_error(1, ret, "io_uring: files registration");
}
if (cfg_reg_ringfd) {
ret = io_uring_register_ring_fd(&ring);
if (ret < 0)
t_error(1, ret, "io_uring: io_uring_register_ring_fd");
}
iov.iov_base = payload;
iov.iov_len = cfg_payload_len;
ret = io_uring_register_buffers(&ring, &iov, 1);
if (ret)
t_error(1, ret, "io_uring: buffer registration");
pthread_barrier_wait(&barrier);
tstop = gettimeofday_ms() + cfg_runtime_ms;
do {
struct io_uring_sqe *sqe;
struct io_uring_cqe *cqe;
unsigned buf_idx = 0;
unsigned msg_flags = MSG_WAITALL;
for (i = 0; i < cfg_nr_reqs; i++) {
sqe = io_uring_get_sqe(&ring);
if (!cfg_zc)
io_uring_prep_send(sqe, fd, payload,
cfg_payload_len, 0);
else {
io_uring_prep_send_zc(sqe, fd, payload,
cfg_payload_len, msg_flags, 0);
if (cfg_fixed_buf) {
sqe->ioprio |= IORING_RECVSEND_FIXED_BUF;
sqe->buf_index = buf_idx;
}
}
sqe->user_data = 1;
if (cfg_fixed_files) {
sqe->fd = 0;
sqe->flags |= IOSQE_FIXED_FILE;
}
}
if (cfg_defer_taskrun && compl_cqes >= notif_slack)
ret = io_uring_submit_and_get_events(&ring);
else
ret = io_uring_submit(&ring);
if (ret != cfg_nr_reqs)
t_error(1, ret, "submit");
for (i = 0; i < cfg_nr_reqs; i++) {
cqe = wait_cqe_fast(&ring);
if (cqe->flags & IORING_CQE_F_NOTIF) {
if (cqe->flags & IORING_CQE_F_MORE)
t_error(1, -EINVAL, "F_MORE notif");
compl_cqes--;
i--;
io_uring_cqe_seen(&ring, cqe);
continue;
}
if (cqe->flags & IORING_CQE_F_MORE)
compl_cqes++;
if (cqe->res >= 0) {
td->packets++;
td->bytes += cqe->res;
} else if (cqe->res == -ECONNREFUSED || cqe->res == -EPIPE ||
cqe->res == -ECONNRESET) {
fprintf(stderr, "Connection failure\n");
goto out_fail;
} else if (cqe->res != -EAGAIN) {
t_error(1, cqe->res, "send failed");
}
io_uring_cqe_seen(&ring, cqe);
}
} while (gettimeofday_ms() < tstop);
out_fail:
shutdown(fd, SHUT_RDWR);
if (close(fd))
t_error(1, errno, "close");
while (compl_cqes) {
struct io_uring_cqe *cqe = wait_cqe_fast(&ring);
io_uring_cqe_seen(&ring, cqe);
compl_cqes--;
}
io_uring_queue_exit(&ring);
}
static void *do_test(void *arg)
{
struct thread_data *td = arg;
int protocol = 0;
setup_sockaddr(cfg_family, str_addr, &td->dst_addr);
do_tx(td, cfg_family, cfg_type, protocol);
pthread_exit(&td->ret);
return NULL;
}
static void usage(const char *filepath)
{
t_error(1, 0, "Usage: %s [-n] [-z] [-s] "
"(-4|-6) [-t