man 1 perf-script
说有现成的脚本可用perf script -l
,但当我调用命令时,它输出
open(/usr/libexec/perf-core/scripts) failed.
Check "PERF_EXEC_PATH" env to set scripts dir.
Perf 本身运行完美,并收集所需的数据。我已经linux-tools-5.13.0-35-generic
安装了与我的内核匹配的 Perf。
我应该安装哪个软件包,还是应该perf
自己重建软件包?我可以从某处复制脚本并修改环境变量吗?
答案1
https://packages.ubuntu.com/search?suite=focal&arch=any&searchon=contents&keywords=scripts%2Fpython%2Fflamegraph.py没有列出任何内容,因此看来您必须从 Linux 内核工具中复制这些内容,就您而言,是从 https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/tree/tools/perf/scripts?h=perf-tools-fixes-for-v5.13-2021-06-19
请注意,实用性取决于您的分布式 perf 是否支持 python 和/或 perl。如果不支持,则需要自行构建 perf,使用:
PERF_VER="perf-tools-fixes-for-v6.1-1-2023-01-06"
KERNEL_REPO="git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git"
sudo apt install -y bison flex libelf-dev libnewt-dev libdw-dev libaudit-dev libiberty-dev libunwind-dev \
libcap-dev libzstd-dev liblzma-dev libnuma-dev libssl-dev systemtap-sdt-dev libbabeltrace-ctf-dev \
libperl-dev libtraceevent-dev \
binutils-dev gcc-multilib \
python3-dev \
libgtk2.0-dev
# asciidoc optional, only for manpages, depdencies are huge
git clone --depth 1 --filter=blob:none --sparse $KERNEL_REPO
cd linux
git sparse-checkout set tools scripts arch
git fetch --depth 1 origin $PERF_VER
export PERF_EXEC_PATH=$PWD/tools/perf
nice make -C $PERF_EXEC_PATH -j $(nproc) PYTHON=/usr/bin/python3
然后你可以使用它
# variable set above
$PERF_EXEC_PATH/perf script -l