我有一台安装了 Xubuntu 18.04 LTS 的联想 T570。我现在的问题是,我的 CPU 速度步进有点疯狂,它只会按照自己认为最好的方式运行。
示例:当我运行 IDE 时,如果在构建期间 CPU 负载增加,调节器会自动更改。我在编译项目时使用以下调用捕捉到了这一时刻:
martin@martin-ThinkPad-T570:~$ while cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor; do sleep 1; done
powersave
powersave
performance
performance
cpufreq-info 告诉我这个:
martin@martin-ThinkPad-T570:~$ cpufreq-info
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to [email protected], please.
analyzing CPU 0:
driver: intel_pstate
CPUs which run at the same hardware frequency: 0
CPUs which need to have their frequency coordinated by software: 0
maximum transition latency: 4294.55 ms.
hardware limits: 400 MHz - 3.50 GHz
available cpufreq governors: performance, powersave
current policy: frequency should be within 3.50 GHz and 3.50 GHz.
The governor "performance" may decide which speed to use
within this range.
current CPU frequency is 3.25 GHz.
analyzing CPU 1:
driver: intel_pstate
CPUs which run at the same hardware frequency: 1
CPUs which need to have their frequency coordinated by software: 1
maximum transition latency: 4294.55 ms.
hardware limits: 400 MHz - 3.50 GHz
available cpufreq governors: performance, powersave
current policy: frequency should be within 3.50 GHz and 3.50 GHz.
The governor "performance" may decide which speed to use
within this range.
current CPU frequency is 3.36 GHz.
analyzing CPU 2:
driver: intel_pstate
CPUs which run at the same hardware frequency: 2
CPUs which need to have their frequency coordinated by software: 2
maximum transition latency: 4294.55 ms.
hardware limits: 400 MHz - 3.50 GHz
available cpufreq governors: performance, powersave
current policy: frequency should be within 3.50 GHz and 3.50 GHz.
The governor "performance" may decide which speed to use
within this range.
current CPU frequency is 3.26 GHz.
analyzing CPU 3:
driver: intel_pstate
CPUs which run at the same hardware frequency: 3
CPUs which need to have their frequency coordinated by software: 3
maximum transition latency: 4294.55 ms.
hardware limits: 400 MHz - 3.50 GHz
available cpufreq governors: performance, powersave
current policy: frequency should be within 3.50 GHz and 3.50 GHz.
The governor "performance" may decide which speed to use
within this range.
current CPU frequency is 3.36 GHz.
请查看
当前政策:频率应在 3.50 GHz 和 3.50 GHz 之间。“性能”调速器可能会决定使用哪种速度
之后,我使用我的小脚本回到省电模式:
martin@martin-ThinkPad-T570:~$ cat cpu_freq_save.sh
#!/bin/bash
sudo cpufreq-set -g powersave -c 0 --min 400MHz
sudo cpufreq-set -g powersave -c 1 --min 400MHz
sudo cpufreq-set -g powersave -c 2 --min 400MHz
sudo cpufreq-set -g powersave -c 3 --min 400MHz
这会重置最小频率和调速器,但只要我每次再次使用 IDE 进行编译,调速器和最小频率就会再次发生变化。
知道如何禁用该自动更改吗?
附言:如果您需要更多详细信息,只需告诉我在哪里可以找到它们,我就会提供它们
答案1
cpufreqd
是一个频率管理守护进程,安装如下:
sudo apt install cpufreqd
配置文件处理器频率配置文件用于更改频率。有两个部分可以看到它将调节器更改为“性能”:
[Profile]
name=hi_boost
minfreq=0%
maxfreq=100%
policy=performance
# full power when AC
[Rule]
name=AC_on
ac=on # (on/off)
profile=hi_boost
除非拔掉电池充电器,否则很难弄清楚何时变为“省电”模式。
从内核 3.4 开始CPU频率内置于内核并自动加载。它包括名为 的频率管理守护进程thermald
。因此,不再需要它cpufreqd
,并且它可能与您的系统发生冲突。
为了在电池供电下实现更大程度的定制,tlp
如今通常使用该套件。
答案2
我尝试了不同的东西,最终cpufreqd
从我的系统中删除了它,只留下了cpufrequtils
安装,然后它就不再在负载下切换调速器了。
以下操作还将删除您的cpufreqd
配置文件,因此如果您计划将来重新安装,请备份它们cpufreqd
。
sudo apt purge cpufreqd
更改应立即生效。将调节器设置为省电后,使用以下命令:
sudo cpupower frequency-set -g powersave
重负载之后,调速器将不再切换到性能。
答案3
如果你打算禁用 intel_pstate 驱动程序,你可以在启动时使用内核参数执行此操作intel_pstate=disable
这可能不符合您的最佳利益,因为 intel_pstate 驱动程序了解 CPU 的工作细节,并且它比通用 ACPI 解决方案做得更好。英特尔声称 intel_pstate“powersave”比具有“性能”的通用 acpi 调节器更快,可能是因为以较高频率执行某些任务会比以较低频率执行需要更多时间的任务(例如算术运算)消耗更少的电量,但并非对所有任务都是如此,例如从内存加载某些内容。
最好的东西你可以做的是忽略它,让 intel_pstate 驱动程序完成它的工作,允许使用TurboBoost 技术内置芯片,可根据功率额定值、温度额定值和电流限制自动调节频率
对于当代的英特尔处理器,如酷睿 i5 7300U您似乎已经知道(尽管您没有提到型号),频率由处理器本身控制,而暴露给软件的 P 状态与性能水平相关。频率可以设置为单一频率的想法对于 Intel Core 处理器来说是虚构的。即使扩展驱动程序选择单一 P 状态,处理器运行的实际频率也由处理器本身选择。
资料来源:
https://unix.stackexchange.com/questions/121410/setting-cpu-governor-to-on-demand-or-conservative