From e0c9c640c69926cea25c82321459e947adf53ff6 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 1 Apr 2021 00:52:42 +0000 Subject: [PATCH] doc: add a page for USDT Signed-off-by: Jim Harris Change-Id: I5aa5ec3c3fc695a2555a34ac4e119e256da464a5 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7195 Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto Reviewed-by: Konrad Sztyber Reviewed-by: Paul Luse --- doc/Doxyfile | 1 + doc/usdt.md | 204 +++++++++++++++++++++++++++++++++++++++++++++ doc/user_guides.md | 1 + 3 files changed, 206 insertions(+) create mode 100644 doc/usdt.md diff --git a/doc/Doxyfile b/doc/Doxyfile index 7ecc216aa..c32c98622 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -843,6 +843,7 @@ INPUT += \ spdk_top.md \ ssd_internals.md \ system_configuration.md \ + usdt.md \ userspace.md \ vagrant.md \ vhost.md \ diff --git a/doc/usdt.md b/doc/usdt.md new file mode 100644 index 000000000..08c258076 --- /dev/null +++ b/doc/usdt.md @@ -0,0 +1,204 @@ +# Userspace DTrace (USDT) {#usdt} + +## Package Dependencies + +These dependencies are needed for building bpftrace and +the sys/sdt.h header file that SPDK libraries will include +for DTRACE_PROBE macro definitions. + +Fedora: +libbpf +gtest-devel +gmock-devel +bcc-devel +systemtap-sdt-devel +llvm-devel +bison +flex + +Ubuntu: +systemtap-sdt-dev +libbpfcc-dev +libclang-7-dev +bison +flex + +## Building bpftrace + +We have found issues with the packaged bpftrace on both Ubuntu 20.04 +and Fedora 33. So bpftrace should be built and installed from source. + +``` +git clone https://github.com/iovisor/bpftrace.git +mkdir bpftrace/build +cd bpftrace/build +cmake -DCMAKE_BUILD_TYPE=Release .. +make +sudo make install +``` + +## bpftrace.sh + +bpftrace.sh is a helper script that facilitates running bpftrace scripts +against a running SPDK application. Here is a typical usage: + +``` +scripts/bpftrace.sh `pidof spdk_tgt` scripts/bpf/nvmf.bt +``` + +Attaching to USDT probes requires the full path of the binary in the +probe description. SPDK bpftrace scripts can be written with an __EXE__ +marker instead of a full path name, and bpftrace.sh will dynamically +replace that string with the full path name using information from procfs. + +It is also useful to filter certain kernel events (such as system calls) +based on the PID of the SPDK application. SPDK bpftrace scripts can be +written with a __PID__ marker, and bpftrace.sh will dynamically replace +that string with the PID provided to the script. + +## Configuring SPDK Build + +``` +./configure --with-usdt +``` + +## Start SPDK application and bpftrace script + +From first terminal: + +``` +build/bin/spdk_tgt -m 0xC +``` + +From second terminal: + +``` +scripts/bpftrace.sh `pidof spdk_tgt` scripts/bpf/nvmf.bt +``` + +nvmf.bt will print information about nvmf subsystem and poll +group info state transitions. + +From third terminal: + +``` +scripts/rpc.py <