From 5a1c74bfa4bd21737dc965b1c539fc356a196295 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Wed, 31 Mar 2021 22:33:20 +0000 Subject: [PATCH] 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 Change-Id: Id168e2c800fa5522815a175026386319014cfdaa Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7173 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Konrad Sztyber Reviewed-by: Aleksey Marchuk Reviewed-by: Ben Walker --- CONFIG | 3 ++ configure | 8 +++++ include/spdk_internal/usdt.h | 59 ++++++++++++++++++++++++++++++++++++ scripts/pkgdep/debian.sh | 2 ++ scripts/pkgdep/rhel.sh | 2 ++ 5 files changed, 74 insertions(+) create mode 100644 include/spdk_internal/usdt.h diff --git a/CONFIG b/CONFIG index 8c49c7d2b..f464f440e 100644 --- a/CONFIG +++ b/CONFIG @@ -172,3 +172,6 @@ CONFIG_RAID5=n # Build with IDXD support CONFIG_IDXD=n + +# Build with USDT support +CONFIG_USDT=n diff --git a/configure b/configure index ce9fba177..95162e9b8 100755 --- a/configure +++ b/configure @@ -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 ;; diff --git a/include/spdk_internal/usdt.h b/include/spdk_internal/usdt.h new file mode 100644 index 000000000..27fef1e2c --- /dev/null +++ b/include/spdk_internal/usdt.h @@ -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 + +#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 */ diff --git a/scripts/pkgdep/debian.sh b/scripts/pkgdep/debian.sh index 88dd5bdea..40149af15 100755 --- a/scripts/pkgdep/debian.sh +++ b/scripts/pkgdep/debian.sh @@ -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 diff --git a/scripts/pkgdep/rhel.sh b/scripts/pkgdep/rhel.sh index 653c57f81..00c82c989 100755 --- a/scripts/pkgdep/rhel.sh +++ b/scripts/pkgdep/rhel.sh @@ -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