Makefile support in DPDK was deprecated and will be removed soon, so switch to the officially supported way of building DPDK - with meson and ninja. Two new tools. Basically, our Makefiles will invoke meson+ninja for DPDK, no other SPDK components are affected. Apparently DPDK wanted to move away from an octopus-like config system and the ideology behind meson configuration is simple now: build everything by default. Some PMDs can be explicitly disabled with meson command line, but all libraries (both static and shared versions) and test apps are built unconditionally. How long does it take to build minimal DPDK with meson? Too much. On my machine half of the total build time is spent on libraries we don't need at all. (I have some hacks up my sleeve to disable building those libraries - see the subsequent patch.) As for the official way of building a minimal DPDK, there was a patch [1] on dpdk mailing list to introduce more specific configuration, but it was rejected: > We talked about this a few times in the past, and it was actually one > of the design goals to _avoid_ replicating the octopus-like config > system of the makefiles. That's because it makes the test matrix > insanely complicated, not to mention the harm to user friendliness, > among other things. > > If someone doesn't want to use a PMD, they can just avoid installing it > - it's simple enough. > > Sorry, but from me it's a very strong NACK. Let's not follow that direction, hack the DPDK build system instead. As for advantages of meson+ninja over Makefiles? I can't find any. It's another build system that does a lot for you with some functions, magic options, and a built-in dependency system. It seems nice if you know the syntax, but it's another component that you need to learn, debug, and possibly find bugs in (there's a lot of github issues open for meson). I would compare it to CMake. As for changes in this patch: rather that explicitly disabling PMDs we don't need, specify a list of PMDs we do need and disable everything else found in ./dpdk/drivers/*. This way we won't have to disable the new PMDs as they're added to DPDK. Meson configuration also sets RTE_EAL_PMD_PATH #define to a valid directory with built PMD shared libs. When it's set, DPDK dynamically loads all shared libraries inside. The drivers there depend on DPDK shared libs and fail to load in static SPDK builds, so we disable them altogether by unsetting RTE_EAL_PMD_PATH in the meson-generated config file - just like DPDK Makefiles did. EAL checks for RTE_EAL_PMD_PATH being empty and skips loading any external PMDs then. We do it for both static and shared libs. We specify all PMDs at build time for now, so there's just no need to load them dynamically. We have three more hacks in our submodule: * disable building dpdk apps by commenting-out a line in dpdk/meson.build * disable building unnecessary libs (build everything that spdk *may* need) * build isa-l compress pmd with `-L[...] -lisal`. DPDK expects to find libisal with pkg-config. We don't want to prepare a pkg-config file, so comment-out a failing check in another meson.build file and provide isa-l through CFLAGS and LDFLAGS. We also need to make some changes to our test/external_code. First of all, -ldpdk is no more. Meson build generates a pkg-config file with all libs, but we'll switch to it in a separate patch - for now just specify all -lrte_ libs one by one. -Wl,--no-as-needed has to be added to some test cases, otherwise rte_mempool_ring isn't loaded. We don't use any APIs from this library, it only has a static constructor that provides a few callbacks used by rte_mempool_create(). Also, since DPDK now builds both static and shared libraries, we need to add -Wl,-Bstatic to force using static libswhere required. It's only needed for DPDK libs, but we use it for SPDK libs as well since there's no harm. As for performance: $ ./configure --enable-debug --with-crypto --with-reduce $ time make -j40 -C dpdkbuild all with meson: real 0m8.287s user 1m7.983s sys 0m10.548s before, with the old DPDK makefiles: real 0m20.232s user 0m55.921s sys 0m16.491s The subsequent builds are much faster too: $ time make -j40 -C dpdkbuild all meson: real 0m0.876s user 0m0.663s sys 0m0.217s makefiles: real 0m10.150s user 0m11.740s sys 0m6.772s [1] http://inbox.dpdk.org/dev/1a07d1cd59d84dce84e56c10fdabf5e5504560a6.camel@debian.org/ Change-Id: Ic65db563014100bafb12e61ee0530cc2ae64401d Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1440 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> |
||
---|---|---|
.githooks | ||
.github/ISSUE_TEMPLATE | ||
app | ||
build/lib | ||
doc | ||
dpdk@a38450c5ae | ||
dpdkbuild | ||
etc/spdk | ||
examples | ||
go | ||
include | ||
intel-ipsec-mb@997d553615 | ||
ipsecbuild | ||
isa-l@f3993f5c0b | ||
isalbuild | ||
lib | ||
mk | ||
module | ||
ocf@9d07955640 | ||
pkg | ||
scripts | ||
shared_lib | ||
test | ||
.astylerc | ||
.gitignore | ||
.gitmodules | ||
autobuild.sh | ||
autopackage.sh | ||
autorun_post.py | ||
autorun.sh | ||
autotest.sh | ||
CHANGELOG.md | ||
CONFIG | ||
configure | ||
CONTRIBUTING.md | ||
LICENSE | ||
Makefile | ||
README.md |
Storage Performance Development Kit
The Storage Performance Development Kit (SPDK) provides a set of tools and libraries for writing high performance, scalable, user-mode storage applications. It achieves high performance by moving all of the necessary drivers into userspace and operating in a polled mode instead of relying on interrupts, which avoids kernel context switches and eliminates interrupt handling overhead.
The development kit currently includes:
- NVMe driver
- I/OAT (DMA engine) driver
- NVMe over Fabrics target
- iSCSI target
- vhost target
- Virtio-SCSI driver
In this readme
- Documentation
- Prerequisites
- Source Code
- Build
- Unit Tests
- Vagrant
- AWS
- Advanced Build Options
- Shared libraries
- Hugepages and Device Binding
- Example Code
- Contributing
Documentation
Doxygen API documentation is available, as well as a Porting Guide for porting SPDK to different frameworks and operating systems.
Source Code
git clone https://github.com/spdk/spdk
cd spdk
git submodule update --init
Prerequisites
The dependencies can be installed automatically by scripts/pkgdep.sh
.
The scripts/pkgdep.sh
script will automatically install the bare minimum
dependencies required to build SPDK.
Use --help
to see information on installing dependencies for optional components
./scripts/pkgdep.sh
Build
Linux:
./configure
make
FreeBSD: Note: Make sure you have the matching kernel source in /usr/src/ and also note that CONFIG_COVERAGE option is not available right now for FreeBSD builds.
./configure
gmake
Unit Tests
./test/unit/unittest.sh
You will see several error messages when running the unit tests, but they are part of the test suite. The final message at the end of the script indicates success or failure.
Vagrant
A Vagrant setup is also provided to create a Linux VM with a virtual NVMe controller to get up and running quickly. Currently this has been tested on MacOS, Ubuntu 16.04.2 LTS and Ubuntu 18.04.3 LTS with the VirtualBox and Libvirt provider. The VirtualBox Extension Pack or [Vagrant Libvirt] (https://github.com/vagrant-libvirt/vagrant-libvirt) must also be installed in order to get the required NVMe support.
Details on the Vagrant setup can be found in the SPDK Vagrant documentation.
AWS
The following setup is known to work on AWS:
Image: Ubuntu 18.04
Before running setup.sh
, run modprobe vfio-pci
then: DRIVER_OVERRIDE=vfio-pci ./setup.sh
Advanced Build Options
Optional components and other build-time configuration are controlled by
settings in the Makefile configuration file in the root of the repository. CONFIG
contains the base settings for the configure
script. This script generates a new
file, mk/config.mk
, that contains final build settings. For advanced configuration,
there are a number of additional options to configure
that may be used, or
mk/config.mk
can simply be created and edited by hand. A description of all
possible options is located in CONFIG
.
Boolean (on/off) options are configured with a 'y' (yes) or 'n' (no). For
example, this line of CONFIG
controls whether the optional RDMA (libibverbs)
support is enabled:
CONFIG_RDMA?=n
To enable RDMA, this line may be added to mk/config.mk
with a 'y' instead of
'n'. For the majority of options this can be done using the configure
script.
For example:
./configure --with-rdma
Additionally, CONFIG
options may also be overridden on the make
command
line:
make CONFIG_RDMA=y
Users may wish to use a version of DPDK different from the submodule included in the SPDK repository. Note, this includes the ability to build not only from DPDK sources, but also just with the includes and libraries installed via the dpdk and dpdk-devel packages. To specify an alternate DPDK installation, run configure with the --with-dpdk option. For example:
Linux:
./configure --with-dpdk=/path/to/dpdk/x86_64-native-linuxapp-gcc
make
FreeBSD:
./configure --with-dpdk=/path/to/dpdk/x86_64-native-bsdapp-clang
gmake
The options specified on the make
command line take precedence over the
values in mk/config.mk
. This can be useful if you, for example, generate
a mk/config.mk
using the configure
script and then have one or two
options (i.e. debug builds) that you wish to turn on and off frequently.
Shared libraries
By default, the build of the SPDK yields static libraries against which
the SPDK applications and examples are linked.
Configure option --with-shared
provides the ability to produce SPDK shared
libraries, in addition to the default static ones. Use of this flag also
results in the SPDK executables linked to the shared versions of libraries.
SPDK shared libraries by default, are located in ./build/lib
. This includes
the single SPDK shared lib encompassing all of the SPDK static libs
(libspdk.so
) as well as individual SPDK shared libs corresponding to each
of the SPDK static ones.
In order to start a SPDK app linked with SPDK shared libraries, make sure to do the following steps:
- run ldconfig specifying the directory containing SPDK shared libraries
- provide proper
LD_LIBRARY_PATH
Linux:
./configure --with-shared
make
ldconfig -v -n ./build/lib
LD_LIBRARY_PATH=./build/lib/ ./build/bin/spdk_tgt
Hugepages and Device Binding
Before running an SPDK application, some hugepages must be allocated and any NVMe and I/OAT devices must be unbound from the native kernel drivers. SPDK includes a script to automate this process on both Linux and FreeBSD. This script should be run as root.
sudo scripts/setup.sh
Users may wish to configure a specific memory size. Below is an example of configuring 8192MB memory.
sudo HUGEMEM=8192 scripts/setup.sh
Example Code
Example code is located in the examples directory. The examples are compiled automatically as part of the build process. Simply call any of the examples with no arguments to see the help output. You'll likely need to run the examples as a privileged user (root) unless you've done additional configuration to grant your user permission to allocate huge pages and map devices through vfio.
Contributing
For additional details on how to get more involved in the community, including contributing code and participating in discussions and other activities, please refer to spdk.io