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   中道学友  阅读(2413)  评论(0编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

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

点击右上角即可分享
微信分享提示