我有一个带有Linux的Raspberry Pi 3。RPi3有一个四核皮质-A53,有一个性能监测单元( v3 ).我执行循环测试程序来做一些实时测试。Cyclcitest是一个乘法,您可以在其中设置周期和迭代次数,并计算延迟。因此,它会执行一些操作,然后进入睡眠状态,直到系统将其唤醒为止。
我希望在每次循环执行中读取缓存内存值,以查看它在执行过程中有多少缓存丢失(我不希望任务处于休眠状态时丢失)。
我尝试过perf执行:
perf stat -o result1.txt -r 10 -i -e armv8_pmuv3/l1d_cache/
-e armv8_pmuv3/l1d_cache_refill/
-e armv8_pmuv3/l1d_cache_wb/
-e armv8_pmuv3/l1d_tlb_refill/
-e armv8_pmuv3/l1i_cache/
-e armv8_pmuv3/l1i_cache_refill/
-e armv8_pmuv3/l1i_tlb_refill/
-e armv8_pmuv3/l2d_cache/
-e armv8_pmuv3/l2d_cache_refill/
-e armv8_pmuv3/l2d_cache_wb/
-e armv8_pmuv3/mem_access/
cyclictest -l57600 -m -n -t1 -p80 -i50000 -h300 -q --histfile=666_data_50然而,它确实提供了大约50%的执行信息:
Performance counter stats for 'cyclictest -l57600 -m -n -t1 -p80 -i50000 -h300 -q --histfile=666_data_50' (10 runs):
937729229 armv8_pmuv3/l1d_cache/ ( +- 2.41% ) (54.50%)
44736600 armv8_pmuv3/l1d_cache_refill/ ( +- 2.33% ) (54.39%)
44784430 armv8_pmuv3/l1d_cache_wb/ ( +- 2.11% ) (54.33%)
294033 armv8_pmuv3/l1d_tlb_refill/ ( +- 13.82% ) (54.21%)
1924752301 armv8_pmuv3/l1i_cache/ ( +- 2.37% ) (54.41%)
120581610 armv8_pmuv3/l1i_cache_refill/ ( +- 2.41% ) (54.46%)
761651 armv8_pmuv3/l1i_tlb_refill/ ( +- 4.87% ) (54.70%)
215103404 armv8_pmuv3/l2d_cache/ ( +- 2.28% ) (54.69%)
30884575 armv8_pmuv3/l2d_cache_refill/ ( +- 1.44% ) (54.83%)
11424917 armv8_pmuv3/l2d_cache_wb/ ( +- 2.03% ) (54.76%)
943041718 armv8_pmuv3/mem_access/ ( +- 2.41% ) (54.74%)
2904.940283006 seconds time elapsed ( +- 0.07% )我不知道这个计数器是在运行时只计算此任务的缓存信息,还是在休眠时计数。有人知道吗?我还有其他应用程序在运行,它们是否可以像我在perf中指定的那样修改这些计数器的值?
如果无法读取任务在运行过程中的计数器的确切值?一个模块还是一个自定义的用户空间应用程序?
谢谢你!!
发布于 2018-03-10 01:00:36
每个性能监视器硬件都受到信道数量的限制:在每个时刻可以同时计数多少个事件。例如,许多现代的x86/x86_64可能为每个cpu核心拥有4个灵活的通道和3个固定的通道。当您向分析器询问更多事件时,它将多路复用(如VTune和帕皮所做的那样)。当多路复用处于活动状态时,某些事件e1占运行时间的55%,perf stat (但不是perf record?) 计数为全速运行时间 ("C. Multiplexing")。这种外推法可能有一些误差。
你的皮质-A53与PMU v3只有六个通道:http://infocenter.arm.com/help/topic/com.arm.doc.ddi0500d/BIIDADBH.html,PMEVCNTR0_EL0 - PMEVCNTR5_EL0和PMEVTYPER0_EL0 - PMEVTYPER5_EL0.尝试使用不超过6个事件启动perf,以关闭事件多路复用:
perf stat -o result1.txt -r 10 -i \
-e armv8_pmuv3/l1d_cache/ \
-e armv8_pmuv3/l1d_cache_refill/ \
-e armv8_pmuv3/l1d_cache_wb/ \
-e armv8_pmuv3/l1d_tlb_refill/ \
-e armv8_pmuv3/l1i_cache/ \
-e armv8_pmuv3/l1i_cache_refill/ \
cyclictest -l57600 -m -n -t1 -p80 -i50000 -h300 -q --histfile=666_data_50
perf stat -o result2.txt -r 10 -i \
-e armv8_pmuv3/l1i_tlb_refill/ \
-e armv8_pmuv3/l2d_cache/ \
-e armv8_pmuv3/l2d_cache_refill/ \
-e armv8_pmuv3/l2d_cache_wb/ \
-e armv8_pmuv3/mem_access/ \
cyclictest -l57600 -m -n -t1 -p80 -i50000 -h300 -q --histfile=666_data_50您还可以尝试将事件分组到集合中:-e \{event1,event2...,event6\} (https://stackoverflow.com/a/48448876)和set will与其他集合多路复用。
https://stackoverflow.com/questions/48926250
复制相似问题