PVE更改governor模式
原创2025年12月12日大约 3 分钟
PVE更改governor模式
背景
PVE工控机器发现CPU温度跳动范围大,风扇转速太快,声音太大
环境信息
PVE版本信息
root@:~# pveversion -v
proxmox-ve: 8.4.0 (running kernel: 6.8.12-15-pve)
pve-manager: 8.4.14 (running version: 8.4.14/b502d23c55afcba1)
proxmox-kernel-helper: 8.1.4
proxmox-kernel-6.8: 6.8.12-15CPU 信息
root@:~# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 39 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 16
On-line CPU(s) list: 0-15
Vendor ID: GenuineIntel
BIOS Vendor ID: Intel(R) Corporation
Model name: 12th Gen Intel(R) Core(TM) i5-1240P
BIOS Model name: 12th Gen Intel(R) Core(TM) i5-1240P To Be Filled By O.E.M. CPU @ 3.4GHz
BIOS CPU family: 205
CPU family: 6
Model: 154
Thread(s) per core: 2
Core(s) per socket: 12
Socket(s): 1
Stepping: 2
CPU(s) scaling MHz: 37%
CPU max MHz: 4400.0000
CPU min MHz: 400.0000常见CPU governor 介绍
| 模式 | 特点 | CPU 行为 | 温度 / 性能影响 | 场景适用 |
|---|---|---|---|---|
| ondemand | 默认模式(动态调速) | 负载高 → 极速升频到最高;负载低 → 快速降频 | 温度峰值可能高,性能最大 | PVE / 一般工作,保性能 |
| powersave | 省电模式 | 自动降低频率,不轻易冲到最高 | 温度低,瞬态高温少,性能略下降 | 长期运行、温控优先 |
| performance | 高性能模式 | CPU 尽量维持高频,少降频 | 温度高,性能最大 | 需要极限性能场景 |
| conservative | 保守模式 | 升频慢,降频快 | 温度低,性能略低 | 低功耗、静音优先 |
| userspace | 用户自定义 | 用户可手动设定固定频率 | 可控,但需要手动设置 | 特殊调度 / 实验场景 |
| schedutil | 内核新模式 | 基于 Linux 调度器动态调频 | 综合温度与性能 | 新内核默认,高性能与温控平衡 |
i5-1240P 举例 (我的CPU)
1️⃣ performance(默认)
- 压测时:几乎全程高频 3.5~4.4GHz
- 温度高,风扇持续加速
- 适合短期性能任务,不适合工控长时间运行
2️⃣ powersave
- 压测时:CPU 多在 2.8~3.2GHz
- 温度峰值降低 5~10℃
- 空闲时仍降到 400MHz
- 优点:温度稳定,适合 7×24
- 缺点:极限性能略低,不影响大部分 VM/CT
操作步骤
确保 linux-cpupower 已安装
apt install linux-cpupower -y
查看当前模式
当前模式
performance
可用模式available cpufreq governors: performance powersave
root@:~# cpupower frequency-info
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: Cannot determine or is not supported.
hardware limits: 400 MHz - 4.40 GHz
available cpufreq governors: performance powersave
current policy: frequency should be within 400 MHz and 4.40 GHz.
The governor "performance" may decide which speed to use
within this range.
current CPU frequency: Unable to call hardware
current CPU frequency: 3.50 GHz (asserted by call to kernel)
boost state support:
Supported: yes
Active: yes更改模式
cpupower frequency-set -g powersave
查看更改后的模式
root@:~# cpupower frequency-info
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: Cannot determine or is not supported.
hardware limits: 400 MHz - 4.40 GHz
available cpufreq governors: performance powersave
current policy: frequency should be within 400 MHz and 4.40 GHz.
The governor "powersave" may decide which speed to use
within this range.
current CPU frequency: Unable to call hardware
current CPU frequency: 1.98 GHz (asserted by call to kernel)
boost state support:
Supported: yes
Active: yes配置开机启动
nano /etc/systemd/system/cpupower-governor.service
[Unit]
Description=Set CPU Governor
After=multi-user.target
[Service]
Type=oneshot
ExecStart=/usr/bin/cpupower frequency-set -g powersave
[Install]
WantedBy=multi-user.target自启动和恢复
systemctl daemon-reload
systemctl enable cpupower-governor
## 想恢复,禁用服务
systemctl disable cpupower-governor