我正在尝试使用linux perf工具监视特定功能期间的性能统计信息.
I'm trying to monitor performance stats during a particular function using linux perf tool.
我正在按照 https:/中给出的说明进行操作/perf.wiki.kernel/index.php/Jolsa_Features_Togle_Event#Example_-_using_u.28ret.29probes
我试图获取一个简单的C程序的指令数. (如下图所示)
I tried to get instruction count of a simple C program. (As shown below)
1)我简单的C代码
#include<stdio.h> int sum=0; int i=0; void func(void) { for(i=0;i<100;i++) { sum=sum+i; } } int main(void) { func(); return 0; }2)编译和添加探针
root@sunimal-laptop:/home/sunimal/temp# gcc -o ex source.c root@sunimal-laptop:/home/sunimal/temp# perf probe -x ./ex entry=func Added new event: probe_ex:entry (on 0x4ed) You can now use it in all perf tools, such as: perf record -e probe_ex:entry -aR sleep 1 root@sunimal-laptop:/home/sunimal/temp# perf probe -x ./ex exit=func%return Added new event: probe_ex:exit (on 0x4ed%return) You can now use it in all perf tools, such as: perf record -e probe_ex:exit -aR sleep 13)尝试使用perf stat来测量func()函数中的指令计数.这会导致错误.
3) Trying to use perf stat to measure the instruction count within the func() function. This leads to an error.
root@sunimal-laptop:/home/sunimal/temp# perf stat -e instructions:u,probe_ex:entry/on=instructions/,probe_ex:exit/off=instructions/ ./ex invalid or unsupported event: 'instructions:u,probe_ex:entry/on=instructions/,probe_ex:exit/off=instructions/' Run 'perf list' for a list of valid events有人可以指出我做错了什么地方吗?
Could someone point me where I did wrong?
[我正在使用Linux内核3.11.0-12-通用]
[I'm using linux kernel 3.11.0-12-generic]
推荐答案我认为您所遵循的说明尚未包含在主线Linux内核中.结果,perf告诉您不支持该事件:perf不知道此页面上提到的切换"机制.
I think that the instructions you are following are not yet included into the mainline Linux kernel. As a consequence, perf is telling you that the events are not supported: perf doesn't know the "toggle" mechanism mentioned on this page.
我可以看到两种解决方法:
I can see two workarounds:
关于2,我对内核版本和开发完全不熟悉,我认为此解决方案的使用和维护可能非常复杂.也许您应该在 perf用户邮件列表上询问是否有任何计划以便将切换功能集成到主线内核中.
Regarding 2, I am not familiar at all with kernel versions and development and I think that this solution may be quie complex to use and maintain. Maybe you should ask on the perf users mailing list if there are any plans for the toggle feature to be integrated into the mainline kernel.
更多推荐
在特定功能期间使用性能探针监视性能统计信息
发布评论