linux-kernel – perf_event_paranoid == 1实际上对x86 perf有什
较新的
Linux内核具有sysfs可调/ proc / sys / kernel / perf_event_paranoid,允许用户为非root用户调整perf_events的可用功能,更高的数字更安全(提供相应更少的功能):
从kernel documenation开始,我们对各种值有以下行为:
我的perf_event_paranoid文件中有1个应该“禁止CPU事件访问” – 但这究竟是什么意思? 普通读数意味着无法访问CPU性能计数器事件(例如Intel PMU事件),但似乎我可以访问那些就好了.例如: $perf stat sleep 1 Performance counter stats for 'sleep 1': 0.408734 task-clock (msec) # 0.000 CPUs utilized 1 context-switches # 0.002 M/sec 0 cpu-migrations # 0.000 K/sec 57 page-faults # 0.139 M/sec 1,050,362 cycles # 2.570 GHz 769,135 instructions # 0.73 insn per cycle 152,661 branches # 373.497 M/sec 6,942 branch-misses # 4.55% of all branches 1.000830821 seconds time elapsed 这里,许多事件是CPU PMU事件(周期,指令,分支,分支未命中,缓存未命中). 如果这些不是所引用的CPU事件,它们是什么? 解决方法
在这种情况下,CPU事件是指监视每个CPU而不是每个任务的事件.对于perf工具,这限制了使用
-C,--cpu= Count only on the list of CPUs provided. Multiple CPUs can be provided as a comma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2. In per-thread mode,this option is ignored. The -a option is still necessary to activate system-wide monitoring. Default is to count on all CPUs. -a,--all-cpus system-wide collection from all CPUs (default if no target is specified) 对于perf_event_open,这考虑以下情况: pid == -1 and cpu >= 0 This measures all processes/threads on the specified CPU. This requires CAP_SYS_ADMIN capability or a /proc/sys/ker |