linux内核中cpu被禁用,如何在Linux内核中禁用perf子系统?

我正在运行一些基准测试.我的基准测试运行器监视实验之间的dmesg缓冲区,寻找可能影响性能的任何事情.今天它把它扔了:

[2015-08-17 10:20:14 WARNING] dmesg seems to have changed! Diff follows:

--- 2015-08-17 09:55:00

+++ 2015-08-17 10:20:14

@@ -825,3 +825,4 @@

[ 3.802206] [drm] Enabling RC6 states: RC6 on,RC6p off,RC6pp off

[ 7.900533] r8169 0000:06:00.0 eth0: link up

[ 7.900541] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

+[236832.221937] perf interrupt took too long (2504 > 2500),lowering kernel.perf_event_max_sample_rate to 50000

@H_502_4@经过一番搜索,我现在知道这与Linux内核中名为“perf”的分析子系统有关.我认为我们不需要这个,所以我想完全禁用它.

@H_502_4@再次搜索,我发现sysctl perf_cpu_time_max_percent可以提供帮助. Here有人建议通过将其设置为0来禁用.阅读此内容更多here:

@H_502_4@perf_cpu_time_max_percent:

@H_502_4@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.

@H_502_4@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.

@H_502_4@0: disable the mechanism. Do not monitor or correct perf’s

sampling rate no matter how cpu time it takes.

@H_502_4@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.

@H_502_4@这听起来像0意味着不再检查分析采样率,但freq子系统仍在运行(?).

@H_502_4@任何人都可以阐明如何使用freq完全禁用内核分析?

@H_502_4@编辑:有人建议我尝试构建一个没有perf的内核,但我认为这甚至不可能.该选项似乎不可切换:

@H_502_4@

@H_502_4@EDIT2:经过更多阅读后,我决定将kernel.perf_event_max_sample_rate设置为零.即每秒没有样品.但是,你也不能这样做(source):

commit 02f98e3e36da106338b7c732fed516420fb20e2a

Author: Knut Petersen

Date: Wed Sep 25 14:29:37 2013 +0200

perf: Enforce 1 as lower limit for perf_event_max_sample_rate

@H_502_4@编辑3:FWIW,perf_cpu_time_max_percent设置为25,这意味着内核花费了超过25%的时间采样硬件寄存器.这对基准测试机来说是不可接受的.

@H_502_4@我现在确定将perf_cpu_time_max_percent设置为零只会使情况恶化,因为内核将继续使用超过25%的时间读取硬件寄存器.该错误触发以调整采样率,从而尝试确保内核满足其使用< 25%的时间在perf中的配额.恕我直言,25%仍然过高. 如果我真的无法禁用perf,可能最好的折衷方案是将perf_event_max_sample_rate设置为1. 编辑4:一位朋友建议我可能误解了perf_cpu_time_max_percent的含义,因此上述陈述可能不正确.值25表示内核使用了超过其保留用于服务性能中断的任意长度的25%. EDIT5: 正如评论中所指出的,针对perf选项的 – * – 表明该功能被另一个启用的功能强制启用.如果我寻求帮助,它会说明这些功能:

@H_502_4@我认为我不能在这里获胜.通过说明选择的布尔公式

@H_502_4@If you are targeting X86,or…

@H_502_4@我刚刚检查过,目标X86_64确实启用了CONFIG_X86.所以看来,只要你瞄准X86或X86_64,就会得到性能.

@H_502_4@所以我想稍微改变一下我的问题:

@H_502_4@Which perf settings can I use to minimise the time spent by the kernel in perf routines?

@H_502_4@请记住,总体目标是控制随机变化的来源以进行基准测试.如果我无法禁用性能,我怎样才能最小化它对基准测试的影响?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值