更多细节:
我使用了'perf stat'命令以10ms的间隔获取硬件计数器事件数据,但它不允许在小于10ms的采样间隔下进行采样。因此,我使用'perf record'代替perf stat以1ms的采样间隔进行采样。以下是一些有用的链接,使我决定使用perf record:Perf Stat vs Perf Record 和 Collecting the data for a partiulcar process from PMU for every 1 milli second
我也尝试过'perf script',但它只支持一些硬件事件。例如:缓存事件不受perf脚本支持。链接:Can't sample hardware cache events with linux perf
请问有谁能帮我解决这个问题吗?请假设我知道如何使用perf record命令,并且已经拥有了从perf record生成的perf.data文件。
编辑:以下是使用答案反馈在终端上的命令及其输出消息:
1) perf record -e LLC-stores,LLC-loads,cache-misses -F 999 -R -T ls>ls.txt
输出:
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.017 MB perf.data (28 samples) ]
2) perf report -F sample,period --stdio
输出:
Total Lost Samples: 0
Samples: 9 of event 'LLC-stores'
Event count (approx.): 7440
Samples Period
............ ............
9 7440
Samples: 9 of event 'LLC-loads'
Event count (approx.): 50008
Samples Period
............ ............
9 50008
Samples: 10 of event 'cache-misses'
Event count (approx.): 351826
Samples Period
............ ............
10 351826
3) perf脚本 -F 周期,事件
输出:
1 LLC-stores:
1 LLC-loads:
1 cache-misses:
1 LLC-loads:
1 cache-misses:
61 LLC-loads:
58 cache-misses:
3097 cache-misses:
1 LLC-stores:
13 LLC-stores:
4748 LLC-loads:
1390 LLC-stores:
190186 cache-misses:
1 LLC-stores:
1 LLC-loads:
1 cache-misses:
1 LLC-loads:
1 cache-misses:
1 LLC-stores:
52 cache-misses:
50 LLC-loads:
20 LLC-stores:
4110 cache-misses:
2002 LLC-loads:
748 LLC-stores:
154319 cache-misses:
43143 LLC-loads:
5265 LLC-stores:
4) perf stat -I 1 -e LLC-stores,LLC-loads,cache-misses ls>ls.txt
输出:
time counts unit events
0.006476856 1,115 LLC-stores
0.006476856 13,121 LLC-loads
0.006476856 9,371 cache-misses
无论是perf report还是perf script,都提供了样本数量、周期和事件名称,但没有每个样本的事件计数。如果您能告诉我如何获取从perf record获得的每28个样本的事件计数,那将非常有帮助。