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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM