SystemTap学习记录
SystemTap 工具
SystemTap 允许用户在不重新编译代码的情况下利用静态追踪、动态追踪工具,比如在任何地方动态插入printk,或者改变内核的关键数据结构(guru模式)。所有的操作都要以root
用户模式下进行。
安装
1 | $ sudo apt install systemtap systemtap-runtime |
安装 kernel debug symbol
1 | # 16.04 或更高 |
基础
-
类 Awk/C 语言
-
可以嵌入到C语言中(guru 模式)
指令
限制
-
SystemTap 可以在内核空间进行追踪,但在用户空间追踪事件取决于内核的支持(Utrace机制)
-
没有内置于内核中,所以性能比eBPF稍差。
-
¶ apps/gmalloc_watch.stp - Tracing glib2 memory allocations
The gmalloc_watch.stp script from Colin Walters’ blog traces the allocation of glib2 memory using the markers in glib2.
1
# stap gmalloc_watch.stp -T 1
-
¶ memory/glibc-malloc.stp - Overview glibc malloc internal operations
This script reports on internal statistics of the glibc malloc implementation, as used by a process restricted by
stap -x/-c
1
# stap glibc-malloc.stp -c 'stap --dump-functions'
-
¶ memory/numa_faults.stp - Summarize Process Misses across NUMA Nodes
The numa_faults.stp script tracks the read and write pages faults for each process. When the script exits it prints out the total read and write pages faults for each process. The script also provide a break down of page faults per node for each process. This script is useful for determining whether the program has good locality (page faults limited to a single node) on a NUMA computer.
-
……
火焰图
http://www.brendangregg.com/FlameGraphs/memoryflamegraphs.html
参考
SystemTap学习记录