我在戴尔 XPS 9510 上运行了最新更新的 Ubuntu 20.04,电池性能真的很差。轻度使用(仅在简单网站上浏览网页)时,我的电池续航时间最多约为 1 小时 30 分钟,而在 Windows 下,笔记本电脑可以轻松达到 8 小时。差别很大。
我检查了很多设置并安装了 TLP 以延长电池寿命,而没有进行重大更改,但是我观察到一种奇怪的行为,这也许可以解释这种高消耗。虽然核心在空闲状态下在负载下可以正确扩展,但频率会回到标称速度(2.5Ghz),而不是最低速度(800Mhz)。
以下是一些输出:
$ sudo tlp-stat -p
--- TLP 1.3.1 --------------------------------------------
+++ Processor
CPU model = 11th Gen Intel(R) Core(TM) i9-11900H @ 2.50GHz
/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver = intel_pstate
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor = powersave
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq = 800000 [kHz]
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq = 4800000 [kHz]
/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference = balance_power [HWP.EPP]
/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power
/sys/devices/system/cpu/cpu1/cpufreq/scaling_driver = intel_pstate
/sys/devices/system/cpu/cpu1/cpufreq/scaling_governor = powersave
/sys/devices/system/cpu/cpu1/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq = 800000 [kHz]
/sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq = 4800000 [kHz]
/sys/devices/system/cpu/cpu1/cpufreq/energy_performance_preference = balance_power [HWP.EPP]
/sys/devices/system/cpu/cpu1/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power
/sys/devices/system/cpu/cpu10/cpufreq/scaling_driver = intel_pstate
/sys/devices/system/cpu/cpu10/cpufreq/scaling_governor = powersave
/sys/devices/system/cpu/cpu10/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu10/cpufreq/scaling_min_freq = 800000 [kHz]
/sys/devices/system/cpu/cpu10/cpufreq/scaling_max_freq = 4800000 [kHz]
/sys/devices/system/cpu/cpu10/cpufreq/energy_performance_preference = balance_power [HWP.EPP]
/sys/devices/system/cpu/cpu10/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power
/sys/devices/system/cpu/cpu11/cpufreq/scaling_driver = intel_pstate
/sys/devices/system/cpu/cpu11/cpufreq/scaling_governor = powersave
/sys/devices/system/cpu/cpu11/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu11/cpufreq/scaling_min_freq = 800000 [kHz]
/sys/devices/system/cpu/cpu11/cpufreq/scaling_max_freq = 4800000 [kHz]
/sys/devices/system/cpu/cpu11/cpufreq/energy_performance_preference = balance_power [HWP.EPP]
/sys/devices/system/cpu/cpu11/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power
/sys/devices/system/cpu/cpu12/cpufreq/scaling_driver = intel_pstate
/sys/devices/system/cpu/cpu12/cpufreq/scaling_governor = powersave
/sys/devices/system/cpu/cpu12/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu12/cpufreq/scaling_min_freq = 800000 [kHz]
/sys/devices/system/cpu/cpu12/cpufreq/scaling_max_freq = 4900000 [kHz]
/sys/devices/system/cpu/cpu12/cpufreq/energy_performance_preference = balance_power [HWP.EPP]
/sys/devices/system/cpu/cpu12/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power
/sys/devices/system/cpu/cpu13/cpufreq/scaling_driver = intel_pstate
/sys/devices/system/cpu/cpu13/cpufreq/scaling_governor = powersave
/sys/devices/system/cpu/cpu13/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu13/cpufreq/scaling_min_freq = 800000 [kHz]
/sys/devices/system/cpu/cpu13/cpufreq/scaling_max_freq = 4900000 [kHz]
/sys/devices/system/cpu/cpu13/cpufreq/energy_performance_preference = balance_power [HWP.EPP]
/sys/devices/system/cpu/cpu13/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power
/sys/devices/system/cpu/cpu14/cpufreq/scaling_driver = intel_pstate
/sys/devices/system/cpu/cpu14/cpufreq/scaling_governor = powersave
/sys/devices/system/cpu/cpu14/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu14/cpufreq/scaling_min_freq = 800000 [kHz]
/sys/devices/system/cpu/cpu14/cpufreq/scaling_max_freq = 4800000 [kHz]
/sys/devices/system/cpu/cpu14/cpufreq/energy_performance_preference = balance_power [HWP.EPP]
/sys/devices/system/cpu/cpu14/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power
/sys/devices/system/cpu/cpu15/cpufreq/scaling_driver = intel_pstate
/sys/devices/system/cpu/cpu15/cpufreq/scaling_governor = powersave
/sys/devices/system/cpu/cpu15/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu15/cpufreq/scaling_min_freq = 800000 [kHz]
/sys/devices/system/cpu/cpu15/cpufreq/scaling_max_freq = 4800000 [kHz]
/sys/devices/system/cpu/cpu15/cpufreq/energy_performance_preference = balance_power [HWP.EPP]
/sys/devices/system/cpu/cpu15/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power
/sys/devices/system/cpu/cpu2/cpufreq/scaling_driver = intel_pstate
/sys/devices/system/cpu/cpu2/cpufreq/scaling_governor = powersave
/sys/devices/system/cpu/cpu2/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq = 800000 [kHz]
/sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq = 4800000 [kHz]
/sys/devices/system/cpu/cpu2/cpufreq/energy_performance_preference = balance_power [HWP.EPP]
/sys/devices/system/cpu/cpu2/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power
/sys/devices/system/cpu/cpu3/cpufreq/scaling_driver = intel_pstate
/sys/devices/system/cpu/cpu3/cpufreq/scaling_governor = powersave
/sys/devices/system/cpu/cpu3/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq = 800000 [kHz]
/sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq = 4800000 [kHz]
/sys/devices/system/cpu/cpu3/cpufreq/energy_performance_preference = balance_power [HWP.EPP]
/sys/devices/system/cpu/cpu3/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power
/sys/devices/system/cpu/cpu4/cpufreq/scaling_driver = intel_pstate
/sys/devices/system/cpu/cpu4/cpufreq/scaling_governor = powersave
/sys/devices/system/cpu/cpu4/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq = 800000 [kHz]
/sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq = 4900000 [kHz]
/sys/devices/system/cpu/cpu4/cpufreq/energy_performance_preference = balance_power [HWP.EPP]
/sys/devices/system/cpu/cpu4/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power
/sys/devices/system/cpu/cpu5/cpufreq/scaling_driver = intel_pstate
/sys/devices/system/cpu/cpu5/cpufreq/scaling_governor = powersave
/sys/devices/system/cpu/cpu5/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu5/cpufreq/scaling_min_freq = 800000 [kHz]
/sys/devices/system/cpu/cpu5/cpufreq/scaling_max_freq = 4900000 [kHz]
/sys/devices/system/cpu/cpu5/cpufreq/energy_performance_preference = balance_power [HWP.EPP]
/sys/devices/system/cpu/cpu5/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power
/sys/devices/system/cpu/cpu6/cpufreq/scaling_driver = intel_pstate
/sys/devices/system/cpu/cpu6/cpufreq/scaling_governor = powersave
/sys/devices/system/cpu/cpu6/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq = 800000 [kHz]
/sys/devices/system/cpu/cpu6/cpufreq/scaling_max_freq = 4800000 [kHz]
/sys/devices/system/cpu/cpu6/cpufreq/energy_performance_preference = balance_power [HWP.EPP]
/sys/devices/system/cpu/cpu6/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power
/sys/devices/system/cpu/cpu7/cpufreq/scaling_driver = intel_pstate
/sys/devices/system/cpu/cpu7/cpufreq/scaling_governor = powersave
/sys/devices/system/cpu/cpu7/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu7/cpufreq/scaling_min_freq = 800000 [kHz]
/sys/devices/system/cpu/cpu7/cpufreq/scaling_max_freq = 4800000 [kHz]
/sys/devices/system/cpu/cpu7/cpufreq/energy_performance_preference = balance_power [HWP.EPP]
/sys/devices/system/cpu/cpu7/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power
/sys/devices/system/cpu/cpu8/cpufreq/scaling_driver = intel_pstate
/sys/devices/system/cpu/cpu8/cpufreq/scaling_governor = powersave
/sys/devices/system/cpu/cpu8/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu8/cpufreq/scaling_min_freq = 800000 [kHz]
/sys/devices/system/cpu/cpu8/cpufreq/scaling_max_freq = 4800000 [kHz]
/sys/devices/system/cpu/cpu8/cpufreq/energy_performance_preference = balance_power [HWP.EPP]
/sys/devices/system/cpu/cpu8/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power
/sys/devices/system/cpu/cpu9/cpufreq/scaling_driver = intel_pstate
/sys/devices/system/cpu/cpu9/cpufreq/scaling_governor = powersave
/sys/devices/system/cpu/cpu9/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu9/cpufreq/scaling_min_freq = 800000 [kHz]
/sys/devices/system/cpu/cpu9/cpufreq/scaling_max_freq = 4800000 [kHz]
/sys/devices/system/cpu/cpu9/cpufreq/energy_performance_preference = balance_power [HWP.EPP]
/sys/devices/system/cpu/cpu9/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power
/sys/devices/system/cpu/intel_pstate/min_perf_pct = 16 [%]
/sys/devices/system/cpu/intel_pstate/max_perf_pct = 100 [%]
/sys/devices/system/cpu/intel_pstate/no_turbo = 0
/sys/devices/system/cpu/intel_pstate/turbo_pct = 57 [%]
/sys/devices/system/cpu/intel_pstate/num_pstates = 41
/sys/module/workqueue/parameters/power_efficient = Y
/proc/sys/kernel/nmi_watchdog = 0
$paste <(ls /sys/devices/system/cpu/cpu0/cpufreq) <(cat /sys/devices/system/cpu/cpu0/cpufreq/*) | column -s $'\t' -t
affected_cpus 0
base_frequency 2500000
cpuinfo_max_freq 4800000
cpuinfo_min_freq 800000
cpuinfo_transition_latency 0
energy_performance_available_preferences default performance balance_performance balance_power power
energy_performance_preference balance_power
related_cpus 0
scaling_available_governors performance powersave
scaling_cur_freq 1103306
scaling_driver intel_pstate
scaling_governor powersave
scaling_max_freq 4800000
scaling_min_freq 800000
scaling_setspeed <unsupported>
$cat /proc/cpuinfo | grep "^[c]pu MHz"
cpu MHz : 2500.000
cpu MHz : 2500.000
cpu MHz : 2500.000
cpu MHz : 2500.000
cpu MHz : 2500.000
cpu MHz : 2500.000
cpu MHz : 2500.000
cpu MHz : 2500.000
cpu MHz : 2500.000
cpu MHz : 1070.651
cpu MHz : 2500.000
cpu MHz : 2500.000
cpu MHz : 1102.344
cpu MHz : 2500.000
cpu MHz : 2500.000
cpu MHz : 2500.000
答案1
我在运行 Ubuntu 22.04 的 XPS 15 9530(2023 型号)上powertop
也遇到了类似的电池续航不佳的情况。我找到了这个工具,它在外接显示器(内接显示器关闭)空闲运行时显示电池耗电量约为 25 瓦。它还显示了一堆“可调参数”,包括“PCI 设备 NVIDIA Corporation 设备 28a0 的运行时 PM”,显然当前设置为“坏”。将其切换到“好”设置可将功耗降低至约 8.5 瓦!这显然大大提高了电池续航时间。
基本上,此设置控制 GPU 的电源管理,显然默认情况下始终处于开启状态。
在我的设备上,此切换按钮的作用是echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/power/control';
。不幸的是,这不会在重启后保留。实现此目的的一种简单方法是以 root 身份编辑 /etc/rc.local(如果不存在,请创建它,不要忘记在顶部添加 shebang(#!/bin/bash)并 chmod a+x /etc/rc.local)(即sudo nano /etc/rc.local
)并添加以下内容:
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/power/control'
;
这应该会在启动时自动启用 GPU 的自动电源管理。希望这对您有所帮助!
答案2
当 CPU 空闲时命令cat /proc/cpuinfo | grep "^[c]pu MHz"
列出 2500.000 时,它仅仅是一个默认的基本频率打印输出,因为实际的 CPU 频率信息已经过时,并且内核不想唤醒休眠的 CPU 只是为了确定其工作频率。
你可以看看/sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
:
doug@s19:~$ uname -a
Linux s19 5.13.0-52-generic #59~20.04.1-Ubuntu SMP Thu Jun 16 21:21:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
doug@s19:~$ grep . /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq:800217
/sys/devices/system/cpu/cpu10/cpufreq/scaling_cur_freq:800279
/sys/devices/system/cpu/cpu11/cpufreq/scaling_cur_freq:800000
/sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq:800004
/sys/devices/system/cpu/cpu2/cpufreq/scaling_cur_freq:800193
/sys/devices/system/cpu/cpu3/cpufreq/scaling_cur_freq:800290
/sys/devices/system/cpu/cpu4/cpufreq/scaling_cur_freq:800143
/sys/devices/system/cpu/cpu5/cpufreq/scaling_cur_freq:801221
/sys/devices/system/cpu/cpu6/cpufreq/scaling_cur_freq:800419
/sys/devices/system/cpu/cpu7/cpufreq/scaling_cur_freq:800160
/sys/devices/system/cpu/cpu8/cpufreq/scaling_cur_freq:800362
/sys/devices/system/cpu/cpu9/cpufreq/scaling_cur_freq:800214
然而,从内核 5.19 开始,它的响应将变为与 /proc/cpuinfo 相同:
doug@s19:~$ uname -a
Linux s19 5.19.0-rc5-stock #1072 SMP PREEMPT_DYNAMIC Mon Jul 4 07:58:15 PDT 2022 x86_64 x86_64 x86_64 GNU/Linux
doug@s19:~$ grep . /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq:4100000
/sys/devices/system/cpu/cpu10/cpufreq/scaling_cur_freq:799988
/sys/devices/system/cpu/cpu11/cpufreq/scaling_cur_freq:4100000
/sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq:4100000
/sys/devices/system/cpu/cpu2/cpufreq/scaling_cur_freq:4100000
/sys/devices/system/cpu/cpu3/cpufreq/scaling_cur_freq:800528
/sys/devices/system/cpu/cpu4/cpufreq/scaling_cur_freq:4100000
/sys/devices/system/cpu/cpu5/cpufreq/scaling_cur_freq:4100000
/sys/devices/system/cpu/cpu6/cpufreq/scaling_cur_freq:4100000
/sys/devices/system/cpu/cpu7/cpufreq/scaling_cur_freq:4100000
/sys/devices/system/cpu/cpu8/cpufreq/scaling_cur_freq:4100000
/sys/devices/system/cpu/cpu9/cpufreq/scaling_cur_freq:4100000
话虽如此,CPU 频率无论如何都不是调查能耗的方法。通常(但绝对不是总是),更高的 CPU 频率可以让任务更快地完成,从而让更多时间处于深度空闲状态,最终减少能耗。大多数 Intel 处理器(过去十年内)以及最近的一些 AMD 处理器的电源监控推荐使用的工具是 turbostat(我认为是 linux-tools-common 包)。示例:
doug@s19:~$ sudo turbostat --Summary --quiet --show Busy%,Bzy_MHz,IRQ,PkgWatt,PkgTmp,RAMWatt,GFXWatt,CorWatt --interval 15
Busy% Bzy_MHz IRQ PkgTmp PkgWatt CorWatt GFXWatt RAMWatt
0.01 1328 425 34 1.42 0.76 0.00 0.89
0.01 800 269 34 1.39 0.73 0.00 0.89 <<< system idle
0.01 800 291 34 1.38 0.72 0.00 0.89
0.01 800 331 34 1.37 0.70 0.00 0.89
81.14 4530 37381 68 110.03 109.37 0.00 0.89
99.05 4513 45191 67 130.44 129.78 0.00 0.89 <<< Big load
99.62 4482 45166 68 124.91 124.25 0.00 0.89 <<< Power limit throttling
99.60 4478 45209 71 124.91 124.25 0.00 0.89
99.58 4473 45171 72 124.92 124.25 0.00 0.89
37.66 4470 17655 43 48.26 47.60 0.00 0.89
0.01 800 315 42 1.52 0.86 0.00 0.89 <<< system idle
0.01 800 316 42 1.50 0.84 0.00 0.89
0.01 800 257 41 1.68 1.02 0.00 0.89