Linux系统安装之后,如何调节CPU性能策略

做了些研究,说一下作为一个Linux初学者对于这个配置方法的理解。


首先,需要知道Linux有一个叫做cpupower的工具集,用来检查和调整处理器的能耗相关的一些features。其中的一个工具叫做“frequency-set”,可以用来调整cpu运行频率。


使用下面的命令来查看当下可用的drivers,即governors:

cpupower frequency-info --governors


# cpupower -c all frequency-info --governors
analyzing CPU 0:
   available cpufreq governors: performance powersave

analyzing CPU 1:
   available cpufreq governors: performance powersave


光手动的用cpupower –c all frequency-set –g performance 来修改是不够的,我们需要让这个配置在开机的时候就生效。所以,需要创建一个由systemd管理的服务,让这个服务在开机的时候就自动运行。

运行下面的命令,直接修改/etc/systemd/system/cpupower.service这个文件,使得这个服务开机就运行一次(oneshot), 不始终保持运行。

$ cat << EOF | sudo tee /etc/systemd/system/cpupower.service
[Unit]
Description=CPU powersave

[Service]
Type=oneshot
ExecStart=/usr/bin/cpupower -c all frequency-set -g powersave

[Install]
WantedBy=multi-user.target
EOF


问题解决。


参考资料

===============

3.2.3. TUNING CPUFREQ POLICY AND SPEED

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/power_management_guide/tuning_cpufreq_policy_and_speed

Performance Tuning Guide for Cisco UCS M4 Servers

https://www.cisco.com/c/en/us/solutions/collateral/data-center-virtualization/unified-computing/whitepaper-c11-737931.html

2.5.2. TUNED-ADM

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/power_management_guide/tuned-adm

How to set CPU governor at system boot

https://blog.sleeplessbeastie.eu/2015/11/09/how-to-set-cpu-governor-at-boot/

Why do most systemd examples contain WantedBy=multi-user.target?

https://unix.stackexchange.com/questions/506347/why-do-most-systemd-examples-contain-wantedby-multi-user-target

4.4. CPU FREQUENCY GOVERNORS

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/performance_tuning_guide/s-cpu-cpufreq

posted on 2020-02-12 20:15  中道学友  阅读(2379)  评论(0编辑  收藏  举报

导航

技术追求准确,态度积极向上