usdt: add User Space DTrace support to SPDK

For now, we will keep this disabled by default,
enable with --with-usdt option to the configure
script.  Long-term we will want to enable this by
default, and only disable via configure.

Modules can include spdk_internal/usdt.h and add
probes such as:

SPDK_DTRACE_PROBE2(probe_name, ptr, val);

When USDT is enabled, these will translate to
DTRACE_PROBE2(spdk, probe_name, ptr, val).  When
USDT is disabled, these will translate to nothing.

Later patches will add some probe points to the
nvmf target, some bpftrace scripts, and instructions
for how to successfully capture data with these
probe points and scripts.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Id168e2c800fa5522815a175026386319014cfdaa
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7173
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Jim Harris 2021-03-31 22:33:20 +00:00 committed by Tomasz Zawadzki
parent 9e1c13c5f1
commit 5a1c74bfa4
5 changed files with 74 additions and 0 deletions

3
CONFIG
View File

@ -172,3 +172,6 @@ CONFIG_RAID5=n
# Build with IDXD support
CONFIG_IDXD=n
# Build with USDT support
CONFIG_USDT=n

8
configure vendored
View File

@ -98,6 +98,8 @@ function usage() {
echo " No path required."
echo " wpdk Build using WPDK to provide support for Windows (experimental)."
echo " The argument must be a directory containing lib and include."
echo " usdt Build with userspace DTrace probes enabled."
echo " No path required."
echo ""
echo "Environment variables:"
echo ""
@ -452,6 +454,12 @@ for i in "$@"; do
--without-idxd)
CONFIG[IDXD]=n
;;
--with-usdt)
CONFIG[USDT]=y
;;
--without-usdt)
CONFIG[USDT]=n
;;
--)
break
;;

View File

@ -0,0 +1,59 @@
/*-
* BSD LICENSE
*
* Copyright (c) Intel Corporation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SPDK_INTERNAL_USDT_H
#define SPDK_INTERNAL_USDT_H
#include "spdk/config.h"
#ifdef SPDK_CONFIG_USDT
#include <sys/sdt.h>
#define SPDK_DTRACE_PROBE(name) DTRACE_PROBE(spdk,name)
#define SPDK_DTRACE_PROBE1(name,a1) DTRACE_PROBE1(spdk,name,a1)
#define SPDK_DTRACE_PROBE2(name,a1,a2) DTRACE_PROBE2(spdk,name,a1,a2)
#define SPDK_DTRACE_PROBE3(name,a1,a2,a3) DTRACE_PROBE3(spdk,name,a1,a2,a3)
#define SPDK_DTRACE_PROBE4(name,a1,a2,a3,a4) DTRACE_PROBE4(spdk,name,a1,a2,a3,a4)
#else
#define SPDK_DTRACE_PROBE(...)
#define SPDK_DTRACE_PROBE1(...)
#define SPDK_DTRACE_PROBE2(...)
#define SPDK_DTRACE_PROBE3(...)
#define SPDK_DTRACE_PROBE4(...)
#endif
#endif /* SPDK_INTERNAL_USDT_H */

View File

@ -27,6 +27,8 @@ fi
apt-get install -y libnuma-dev
# Additional dependencies for ISA-L used in compression
apt-get install -y autoconf automake libtool help2man
# Additional dependencies for USDT
apt-get install -y systemtap-sdt-dev
if [[ $INSTALL_DEV_TOOLS == "true" ]]; then
# Tools for developers
apt-get install -y git astyle pep8 lcov clang sg3-utils pciutils shellcheck abigail-tools bash-completion

View File

@ -104,6 +104,8 @@ fi
yum install -y autoconf automake libtool help2man
# Additional dependencies for DPDK
yum install -y numactl-devel nasm
# Additional dependencies for USDT
yum install -y systemtap-sdt-devel
if [[ $INSTALL_DEV_TOOLS == "true" ]]; then
# Tools for developers
if echo "$ID $VERSION_ID" | grep -E -q 'centos 8'; then