Linux   发布时间:2022-04-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了linux-kernel – perf_event_paranoid == 1实际上对x86 perf有什么限制?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

较新的 Linux内核具有sysfs可调/ proc / sys / kernel / perf_event_paranoid,允许用户为非root用户调整perf_events的可用功能,更高的数字更安全(提供相应更少的功能): 从kernel documenation开始,我们对各种值有以下行为: perf_event_paranoid: Controls use of the perform
@H_450_10@
较新的 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‐
       nel/perf_event_paranoid value of less than 1.

这可能是特定于版本的,引用的文档来自4.17.这是another related question.

大佬总结

以上是大佬教程为你收集整理的linux-kernel – perf_event_paranoid == 1实际上对x86 perf有什么限制?全部内容,希望文章能够帮你解决linux-kernel – perf_event_paranoid == 1实际上对x86 perf有什么限制?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。