arm linux 生成火焰图

aarch32  arm-linux-gnueabihf-gcc linux4.9

perf wiki:https://perf.wiki.kernel.org/index.php/Tutorial

perf 工具生成:

cd linux/tools/perf  

./build.sh

perf 采集栈信息的linux支持

CONFIG_PERF_EVENTS=y
CONFIG_HW_PERF_EVENTS=y

CONFIG_SCHED_INFO=y
CONFIG_SCHEDSTATS=y

ONFIG_KALLSYMS=y
CONFIG_KALLSYMS_ALL=y

CONFIG_DEBUG_INFO=y

CONFIG_FTRACE=y (enable debugfs tracing)

根据README

1.采集命令./perf record -F [sample freq] -p [pid] -g -- sleep [time]

ON-CPU:

perf record -F 99 -p 1140 -g -- sleep 60

OFF-CPU:

perf record -e sched:sched_stat_sleep -e sched:sched_switch -e sched:sched_process_exit -p [pid] -g -o perf.data.raw sleep 10
perf inject -v -s -i perf.data.raw -o perf.data

2.生成火焰图:

下载生成火焰图的脚本 https://github.com/brendangregg/FlameGraph

perf script > out.perf

stackcollapse-perf.pl out.perf > out.folded

flamegraph.pl out.folded > kernel.svg

3. 示例展示

ON-CPU

arm linux 生成火焰图_第1张图片

OFF-CPU

perf inject 出现error :failed to write feature BUILD_ID

./perf inject -b -v -s -i ./perf.data.raw -o ./perf.data

加-b参数(参见tools/perf/Documents/)后错误变成:Failed to open /proc/kcore. Note /proc/kcore requires CAP_SYS_RAWIO capability to access. Using /proc/kallsyms for symbols,这个错误可以忽略

发现有很多unknown symbol

echo 1 > /proc/sys/kernel/perf_event_paranoid

echo 0 > /proc/sys/kernel/kptr_restrict

你可能感兴趣的:(LINUX,ARM)