perf: interrupt took too long

Perf 问题

最近Linux 内核总是报一下错误信息,所以抽出点时间找了点资料了解了下:

[ 6216.961770] perf: interrupt took too long (2502 > 2500), lowering kernel.perf_event_max_sample_rate to 79000

发现在红帽的Bugzilla上已经有人提出过这个bug了,瞬间感觉轻松了不少,通读之后可以确定是Linux 内核perf 功能在打开的状态可以通过调节参数来修改这个问题。

最后找到一个关于这个bug相关的patch, 通过内核的注释可以看到一些内容,这些参数是在调试的时候比较有用的。

这个文件有详细的说明 : Documentation/sysctl/kernel.txt

+perf_cpu_time_max_percent:
+
+Hints to the kernel how much CPU time it should be allowed to
+use to handle perf sampling events.  If the perf subsystem
+is informed that its samples are exceeding this limit, it
+will drop its sampling frequency to attempt to reduce its CPU
+usage.
+
+Some perf sampling happens in NMIs.  If these samples
+unexpectedly take too long to execute, the NMIs can become
+stacked up next to each other so much that nothing else is
+allowed to execute.
+
+0: disable the mechanism.  Do not monitor or correct perf's
+   sampling rate no matter how CPU time it takes.
+
+1-100: attempt to throttle perf's sample rate to this
+   percentage of CPU.  Note: the kernel calculates an
+   "expected" length of each sample event.  100 here means
+   100% of that expected length.  Even if this is set to
+   100, you may still see sample throttling if this
+   length is exceeded.  Set to 0 if you truly do not care
+   how much CPU is consumed.
+
  • 2
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Perf是一款Linux内核自带的程序性能分析工具,可以用于分析程序的CPU时间占用情况、函数调用关系、缓存命中率等信息。下面是使用Perf进行程序性能分析的步骤: 1. 安装PerfPerf通常已经预装在Linux系统中,如果没有安装,可以使用以下命令安装: ``` sudo apt-get install linux-tools-common linux-tools-generic linux-tools-$(uname -r) ``` 2. 编译程序时添加-g选项:Perf需要程序符号表信息才能进行函数调用关系的分析,因此需要在编译程序时添加-g选项,例如: ``` gcc -g -o myprogram myprogram.c ``` 3. 运行Perf:运行Perf需要使用root权限,因为Perf需要访问系统的计数器和内核数据结构。使用以下命令运行Perf: ``` sudo perf record -g ./myprogram ``` 该命令将会启动Perf进行性能分析,-g选项表示要收集函数调用关系信息。 4. 分析性能数据:Perf会将性能数据保存在perf.data文件中,可以使用以下命令查看性能数据: ``` sudo perf report ``` 该命令将会启动Perf进行性能数据分析,生成一个报告,包含了程序的函数调用关系、CPU时间占用情况、缓存命中率等信息。 以上是使用Perf进行程序性能分析的基本步骤,需要根据具体的情况和需求进行调整和优化。例如,可以使用Perf的更多选项和参数来收集更详细的性能数据,也可以使用Perf的插件和可视化工具来更方便地分析性能数据。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值