有perf mem
实施的工具some现代 x86/EM64T CPU(可能仅支持 Intel;Ivy 和更新的桌面/服务器 cpu)。的手册页perf mem
is http://man7.org/linux/man-pages/man1/perf-mem.1.html http://man7.org/linux/man-pages/man1/perf-mem.1.html和内核文档目录中的相同文本:http://lxr.free-electrons.com/source/tools/perf/Documentation/perf-mem.txt http://lxr.free-electrons.com/source/tools/perf/Documentation/perf-mem.txt。文字不完整;最好的文档是来源:工具/perf/builtin-mem.c http://lxr.free-electrons.com/source/tools/perf/builtin-mem.c&部分在工具/perf/builtin-report.c http://lxr.free-electrons.com/source/tools/perf/builtin-mem.c?v=4.10#L264。没有详细信息https://perf.wiki.kernel.org/index.php/Tutorial https://perf.wiki.kernel.org/index.php/Tutorial.
Unlike qemu-mtrace
它不会记录每次内存访问,而只会记录第 N 次访问,其中 N 类似于 10000 或 100000。但它以本机速度和低开销运行。使用perf mem record ./program
记录模式;尝试添加-a
or -C cpulist
用于某些 CPU 内核的系统范围或全局采样。没有办法记录(跟踪)系统内部的所有和每个内存访问(工具应该将信息写入内存并记录此访问 - 这是有限内存的无限递归),但是有非常昂贵的专有系统特定外部跟踪解决方案,如 JTAG 或 SDRAM 嗅探器(5000 美元或更多)。
的工具perf mem
其中2013年左右添加(3.10版本的linux内核),在lwn上搜索perf mem有几个结果:https://lwn.net/Articles/531766/ https://lwn.net/Articles/531766/
使用此补丁,可以对内存进行采样(而不是跟踪)
访问(加载、存储)。对于负载,指令和数据
地址与延迟和数据源一起被捕获。
对于存储,指令和数据地址被捕获
以及有限的缓存和 TLB 信息。
目前的补丁
在从 Nehalem 开始的 Intel 处理器上实现该功能。
这些补丁利用 PEBS 加载延迟和精确存储
机制。 Precise Store 仅存在于 Sandy Bridge 和
基于 Ivy Bridge 的处理器。
添加了物理地址采样支持:https://lwn.net/Articles/555890/ https://lwn.net/Articles/555890/ (perf mem --phys-addr -t load rec
); (还有一点相关的2016年c2c
性能工具“跟踪缓存行争用": https://lwn.net/Articles/704125/ https://lwn.net/Articles/704125/举例说明https://joemario.github.io/blog/2016/09/01/c2c-blog/ https://joemario.github.io/blog/2016/09/01/c2c-blog/)
一些随机幻灯片perf mem
:
- http://indico.cern.ch/event/280897/contributions/1628882/attachments/515361/711133/SE-CERN_PMU_workshop_2013.pdf#page=4 http://indico.cern.ch/event/280897/contributions/1628882/attachments/515361/711133/SE-CERN_PMU_workshop_2013.pdf#page=4
- http://www.linuxtag.org/2013/fileadmin/www.linuxtag.org/slides/Arnaldo_Melo__-_Linux__perf__tools__Overview_and_Current_Developments.e323.pdf#page=10 http://www.linuxtag.org/2013/fileadmin/www.linuxtag.org/slides/Arnaldo_Melo_-_Linux__perf__tools__Overview_and_Current_Developments.e323.pdf#page=10
- https://people.netfilter.org/pablo/netdev0.1/slides/sowa-perf-analytics.pdf#page=19 https://people.netfilter.org/pablo/netdev0.1/slides/sowa-perf-analytics.pdf#page=19
有关解码的一些信息perf mem -D report
: perf mem -D 报告 https://stackoverflow.com/questions/33295288
# PID, TID, IP, ADDR, LOCAL WEIGHT, DSRC, SYMBOL
2054 2054 0xffffffff811186bf 0x016ffffe8fbffc804b0 49 0x68100842 /lib/modules/3.12.23/build/vmlinux:perf_event_aux_ctx
“地址”、“DSRC”、“符号”是什么意思?
(与此答案相同的用户回答)
- IP——加载/存储指令的PC;
- SYMBOL - 函数名称,包含该指令(IP);
- ADDR - 数据的虚拟内存地址,由加载/存储请求(如果没有 --phys-data 选项)
- DSRC - “解码源”。
还可以通过排序来获取一些基本统计数据:perf mem rep --sort=mem
- http://thread.gmane.org/gmane.linux.kernel.perf.user/1438 http://thread.gmane.org/gmane.linux.kernel.perf.user/1438
其他工具..有(慢)cachegrindemulator基于 valgrind 来模拟用户空间程序的高速缓存 - 《7.2 模拟 CPU 高速缓存》https://lwn.net/Articles/257209/ https://lwn.net/Articles/257209/。还应该有一些与 DRAMsim/DRAMsim2 相关的低级(最慢)模型http://eng.umd.edu/~blj/dramsim/ http://eng.umd.edu/~blj/dramsim/