经过一些阅读后,似乎正确的做法是将cpu调控器更改为性能,如here in the Linux kernel documentation所述:
The cpufreq governor “performance” sets the cpu statically to the
highest frequency within the borders of scaling_min_freq and
scaling_max_freq.
遗憾的是,未提供有关scaling_min_freq和scaling_max_freq的更多详细信息.希望它无关紧要,因为使用的cpu频率是间隔的最大值.
所以我使用cpufreq-set启用了这个调控器:
$cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor performance performance performance performance
为了更好的衡量,我还在BIOS中禁用了turbo boost模式:
$cat /sys/devices/system/cpu/intel_pstate/no_turbo 1
基于以上对性能调控器的描述,我预计cpu时钟速度不会有波动.然而,如果我反复运行cpufreq-info,我会看到时钟速度波动:
$cpufreq-info | grep 'current cpu fr' current cpu frequency is 4.00 GHz. current cpu frequency is 3.99 GHz. current cpu frequency is 4.00 GHz. current cpu frequency is 4.00 GHz. $cpufreq-info | grep 'current cpu fr' current cpu frequency is 4.00 GHz. current cpu frequency is 4.00 GHz. current cpu frequency is 4.00 GHz. current cpu frequency is 3.96 GHz. $cpufreq-info | grep 'current cpu fr' current cpu frequency is 4.00 GHz. current cpu frequency is 4.00 GHz. current cpu frequency is 4.00 GHz. current cpu frequency is 3.94 GHz. $cpufreq-info | grep 'current cpu fr' current cpu frequency is 4.01 GHz. current cpu frequency is 4.00 GHz. current cpu frequency is 4.00 GHz. current cpu frequency is 3.98 GHz.
这种波动是由于硬件,BIOS,内核还是其他因素造成的?有没有办法设置cpu频率,使其根本不会波动?
解决方法
如in this thread所述,在某些英特尔硬件上,有两种方法可以管理cpu频率:
>使用pstate.
>使用常规ACPI.
当使用pstate时,BIOS在时钟速度上有一些说法,似乎这是波动的来源.
您可以通过将intel_pstate = disable附加到内核参数来强制关闭pstate(编辑/ etc / default / grub并将arg添加到GRUB_CMDLINE_LINUX_DEFAULT.最后运行sudo update-grub).
执行此操作后,cpufreq-info的输出看起来大不相同,我还注意到一组不同的cpu管理器可用(例如,现在可以使用ondemand).
最重要的是,在将调速器设置为性能之后,时钟速度现在已经固定(在我的情况下为4.00GHz).
您可以查看/ sys / devices / system / cpu / cpu * / cpufreq / scaling_driver以确定是否正在使用pstate或ACPI来扩展cpu.这些文件可以采用值acpi-cpufreq或intel_pstate.