[已解决] Intel lunar lake Ultra7 258V 使用 balance 能源模式卡顿

我正在使用 Thinkpad X1 Carbon gen 13, 我的CPU是 Intel Lunar lake Ultra7 258V. 我的内核版本是 6.14.1-arch1-1, 桌面环境是 KDE. 我安装了 power-profiles-daemon 进行调频. 我发现如果我把 Power profile 设置成 balance 后不久, 我的系统就会卡顿. 我发现 CPU 频率一直保持在很低的范围 (大概 400MHz 左右).

$ cpupower frequency-info
-------------------------------------------------------------------------
analyzing CPU 3:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 3
  CPUs which need to have their frequency coordinated by software: 3
  energy performance preference: balance_power
  hardware limits: 400 MHz - 4.80 GHz
  available cpufreq governors: performance powersave
  current policy: frequency should be within 400 MHz and 4.80 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency: 400 MHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: yes

然而在 power save 或者 performance 模式下我的电脑正常工作.


更新一下, 使用 thermald 可能不太被推荐 (见这个Github Issue), 这个问题更新 BIOS 到最新版本就解决了.

那就用 powersave 啊。「balance」是用的哪个 driver 呢?

确实我几乎一直在用 powersave, 最近才发现有这个问题. balanced 是我在 KDE 下设置的能源模式, 我想他应该指的是

  energy performance preference: balance_power

这一行, driver 应该一直是 intel_pstate.

我想这应该对应于 https://wiki.archlinux.org/title/CPU_frequency_scaling#Intel_performance_and_energy_bias_hint 在 power save 模式下有

$ cat /sys/devices/system/cpu/cpu0/power/energy_perf_bias
15

在 balanced 模式下有

$ cat /sys/devices/system/cpu/cpu0/power/energy_perf_bias
8

我想起来以前装 TLP 的时候感觉很卡顿, 就换成了 power-profiles-daemon, 现在看来不是 TLP 的问题 ,

好奇怪这好像又不是 Intel performance and energy bias hint, 我参照 https://wiki.archlinux.org/title/CPU_frequency_scaling#Intel_performance_and_energy_bias_hint 的三个方法设置 EPB 值, 发现虽然 /sys/devices/system/cpu/cpu*/power/energy_perf_bias 的值变化了, 但是卡顿问题没有出现, 而且 cpupower frequency-info 中 energy performance preference 也没有从 power 变成 balance_power. 懵, 不知道 power-profiles-daemon 调的到底是什么.

另外如果我把 power-profiles-daemon 卸载且把服务停止, 那么卡顿问题就会出现, 看起来好像也不是 power-profiles-daemon 的 bug?

https://wiki.archlinux.org/title/CPU_frequency_scaling#Setting_the_EPP

参考 https://unix.stackexchange.com/a/664093, 我把 Windows 能源模式调整为了最佳性能 (电池和电源供电都设置了). 目前看来问题好像已经被解决了, 太神秘了, 我不知道发生了什么 :o


对不起看起来不是这样, 坚持了一小会后 CPU 又开始限制在很低的频率了 :frowning:

试试 intel_pstate=passive 这个 kernel parameter?感觉可能是有啥 bug,lunar lake 还是太新了

我尝试了这个, 但是问题还在 (sad) :frowning:

$ cpupower frequency-info
----------------------------------------------
analyzing CPU 6:
  driver: intel_cpufreq
  CPUs which run at the same hardware frequency: 6
  CPUs which need to have their frequency coordinated by software: 6
  energy performance preference: balance_performance
  hardware limits: 400 MHz - 3.70 GHz
  available cpufreq governors: conservative ondemand userspace powersave performance schedutil
  current policy: frequency should be within 400 MHz and 3.70 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
  current CPU frequency: 400 MHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: yes

调整到 balanced 后没多久 (大概半分钟?) CPU 频率就被限制到 400MHz 左右. 不管是电源供电还是电池供电都是如此.

我怀疑是 Thinkpad 的问题 (例如 https://wiki.archlinux.org/title/Lenovo_ThinkPad_T480#CPU_stuck_at_minimum_frequency), 但是我现在没有时间调试这个, 毕竟 powersave 已经够用了 :expressionless:

我很久没用过 intel 的 cpu 的机器了,看起来是

  energy performance preference: balance_performance

这一行会影响 cpu 的频率?这个就是 power-profiles-daemon 和 tlp 控制的部分(我记得 tlp 似乎有配置这个相关的选项)?不过我这边 amd 的 cpu 上的 cpupower frequency-info 并没有这一行。。

太神秘了, 我刚刚发现只要我进行如下操作:

  1. 启动 Windows 并在电源设置里更改能源模式 (如平衡 -> 最佳能效).
  2. 重启进入 Archlinux.

那么在Archlinux下第一次设置 balanced 模式不会出现卡顿(通过KDE的托盘面板). 但是如果切换了模式 (如 balanced -> performance -> balanced), 那么过了大概半分钟就会出现同样的问题 :frowning:

analyzing CPU 1:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 1
  CPUs which need to have their frequency coordinated by software: 1
  energy performance preference: balance_performance
  hardware limits: 400 MHz - 4.70 GHz
  available cpufreq governors: performance powersave
  current policy: frequency should be within 400 MHz and 4.70 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency: 1.07 GHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: yes

(可以看到 energy performance preference: balance_performance 而且 CPU 频率正常)

我完全晕过去了qwq

贴一个 balanced 下 turbostat 的输出不知道有没有帮助 (

# turbostat
--------------------
turbostat version 2025.02.02 - Len Brown <lenb@kernel.org>
Kernel command line: BOOT_IMAGE=/@/boot/vmlinuz-linux root=UUID=**** rw rootflags=subvol=@ loglevel=3 quiet
CPUID(0): GenuineIntel 0x23 CPUID levels
CPUID(1): family:model:stepping 0x6:bd:1 (6:189:1) microcode 0x116
CPUID(0x80000000): max_extended_levels: 0x80000008
CPUID(1): SSE3 MONITOR SMX EIST TM2 TSC MSR ACPI-TM HT TM
CPUID(6): APERF, TURBO, DTS, PTM, HWP, HWPnotify, HWPwindow, HWPepp, HWPpkg, EPB
cpu0: MSR_IA32_MISC_ENABLE: 0x00850089 (TCC EIST MWAIT PREFETCH TURBO)
CPUID(7): No-SGX Hybrid
CPUID(0x15): eax_crystal: 2 ebx_tsc: 172 ecx_crystal_hz: 38400000
TSC: 3302 MHz (38400000 Hz * 172 / 2 / 1000000)
CPUID(0x16): base_mhz: 3300 max_mhz: 3700 bus_mhz: 100
cpu0: MSR_PLATFORM_INFO: 0x804043df0812100
4 * 100.0 = 400.0 MHz max efficiency frequency
33 * 100.0 = 3300.0 MHz base frequency
cpu0: MSR_TURBO_RATIO_LIMIT: 0x2a2a2a2a2a2d3030
42 * 100.0 = 4200.0 MHz max turbo 8 active cores
42 * 100.0 = 4200.0 MHz max turbo 7 active cores
42 * 100.0 = 4200.0 MHz max turbo 6 active cores
42 * 100.0 = 4200.0 MHz max turbo 5 active cores
42 * 100.0 = 4200.0 MHz max turbo 4 active cores
45 * 100.0 = 4500.0 MHz max turbo 3 active cores
48 * 100.0 = 4800.0 MHz max turbo 2 active cores
48 * 100.0 = 4800.0 MHz max turbo 1 active cores
cpu0: MSR_SECONDARY_TURBO_RATIO_LIMIT: 0x2525252525252525
37 * 100.0 = 3700.0 MHz max turbo 8 active cores
37 * 100.0 = 3700.0 MHz max turbo 7 active cores
37 * 100.0 = 3700.0 MHz max turbo 6 active cores
37 * 100.0 = 3700.0 MHz max turbo 5 active cores
37 * 100.0 = 3700.0 MHz max turbo 4 active cores
37 * 100.0 = 3700.0 MHz max turbo 3 active cores
37 * 100.0 = 3700.0 MHz max turbo 2 active cores
37 * 100.0 = 3700.0 MHz max turbo 1 active cores
cpu0: MSR_CONFIG_TDP_NOMINAL: 0x00000016 (base_ratio=22)
cpu0: MSR_CONFIG_TDP_LEVEL_1: 0x00100040 (PKG_MIN_PWR_LVL1=0 PKG_MAX_PWR_LVL1=0 LVL1_RATIO=16 PKG_TDP_LVL1=64)
cpu0: MSR_CONFIG_TDP_LEVEL_2: 0x002100f0 (PKG_MIN_PWR_LVL2=0 PKG_MAX_PWR_LVL2=0 LVL2_RATIO=33 PKG_TDP_LVL2=240)
cpu0: MSR_CONFIG_TDP_CONTROL: 0x00000000 ( lock=0)
cpu0: MSR_TURBO_ACTIVATION_RATIO: 0x00000015 (MAX_NON_TURBO_RATIO=21 lock=0)
cpu0: cpufreq driver: intel_pstate
cpu0: cpufreq governor: powersave
cpufreq intel_pstate no_turbo: 0
cpu0: MSR_MISC_PWR_MGMT: 0x000030c2 (ENable-EIST_Coordination ENable-EPB DISable-OOB)
cpu0: MSR_PM_ENABLE: 0x00000001 (HWP)
cpu0: MSR_HWP_CAPABILITIES: 0x01121a38 (high 56 guar 26 eff 18 low 1)
cpu0: MSR_HWP_REQUEST: 0x80003805 (min 5 max 56 des 0 epp 0x80 window 0x0 pkg 0x0)
cpu0: MSR_HWP_REQUEST_PKG: 0x8000ff01 (min 1 max 255 des 0 epp 0x80 window 0x0)
cpu0: MSR_HWP_INTERRUPT: 0x00000005 (EN_Guaranteed_Perf_Change, Dis_Excursion_Min)
cpu0: MSR_HWP_STATUS: 0x00000000 (No-Guaranteed_Perf_Change, No-Excursion_Min)
cpu0: EPB: 6 (balanced)
cpu0: MSR_IA32_POWER_CTL: 0x00e4005b (C1E auto-promotion: ENabled)
cpu0: MSR_PKG_CST_CONFIG_CONTROL: 0x74008008 (UNdemote-C1, demote-C1, locked, pkg-cstate-limit=8 (unlimited))
/dev/cpu_dma_latency: 2000000000 usec (default)
current_driver: intel_idle
current_governor: menu
current_governor_ro: menu
cpu0: POLL: CPUIDLE CORE POLL IDLE
cpu0: C1ACPI: ACPI FFH MWAIT 0x0
cpu0: C2ACPI: ACPI FFH MWAIT 0x21
cpu0: C3ACPI: ACPI FFH MWAIT 0x60
cpu0: MSR_PKGC6_IRTL: 0x00000000 (NOTvalid, 0 ns)
cpu0: MSR_PKGC10_IRTL: 0x00000000 (NOTvalid, 0 ns)
Uncore Frequency package0 die0: 400 - 4600 MHz (400 - 4600 MHz) 400 MHz
RAPL: 15420 sec. Joule Counter Range, at 17 Watts
cpu0: MSR_RAPL_POWER_UNIT: 0x000a0e03 (0.125000 Watts, 0.000061 Joules, 0.000977 sec.)
cpu0: MSR_PKG_POWER_INFO: 0x00000088 (17 W TDP, RAPL 0 - 0 W, 0.000000 sec.)
cpu0: MSR_PKG_POWER_LIMIT: 0x812800dd8128 (UNlocked)
cpu0: PKG Limit #1: ENabled (37.000 Watts, 28.000000 sec, clamp ENabled)
cpu0: PKG Limit #2: ENabled (37.000 Watts, 0.000977* sec, clamp DISabled)
cpu0: MSR_VR_CURRENT_CONFIG: 0x000002f8
cpu0: PKG Limit #4: 95.000000 Watts (UNlocked)
cpu0: MSR_DRAM_POWER_LIMIT: 0x00000000 (UNlocked)
cpu0: DRAM Limit: DISabled (0.000 Watts, 0.000977 sec, clamp DISabled)
cpu0: MSR_PP0_POLICY: 0
cpu0: MSR_PP0_POWER_LIMIT: 0x00000000 (UNlocked)
cpu0: Cores Limit: DISabled (0.000 Watts, 0.000977 sec, clamp DISabled)
cpu0: MSR_PP1_POLICY: 0
cpu0: MSR_PP1_POWER_LIMIT: 0x00000000 (UNlocked)
cpu0: GFX Limit: DISabled (0.000 Watts, 0.000977 sec, clamp DISabled)
cpu0: MSR_IA32_TEMPERATURE_TARGET: 0x05640000 (95 C) (100 default - 5 offset)
cpu0: MSR_IA32_PACKAGE_THERM_STATUS: 0x88390c00 (43 C)
cpu0: MSR_IA32_PACKAGE_THERM_INTERRUPT: 0x02000003 (100 C, 100 C)
cpu0: MSR_MISC_FEATURE_CONTROL: 0x00000000 (L2-Prefetch L2-Prefetch-pair L1-Prefetch L1-IP-Prefetch)

我刚刚安装了 thermald 并启动他, 得到

○ thermald.service - Thermal Daemon Service
     Loaded: loaded (/usr/lib/systemd/system/thermald.service; disabled; preset: disabled)
     Active: inactive (dead)

4月 14 18:58:04 PsiThinkpadArch systemd[1]: Starting Thermal Daemon Service...
4月 14 18:58:04 PsiThinkpadArch thermald[26878]: 35 CPUID levels; family:model:stepping 0x6:bd:1 (6:189:1)
4月 14 18:58:04 PsiThinkpadArch thermald[26878]: [/sys/devices/platform/thinkpad_acpi/dytc_lapmode] present: Thermald can't run on this platform
4月 14 18:58:04 PsiThinkpadArch thermald[26878]: Unsupported cpu model or platform
4月 14 18:58:04 PsiThinkpadArch thermald[26878]: Try option --ignore-cpuid-check to disable this compatibility test
4月 14 18:58:04 PsiThinkpadArch systemd[1]: thermald.service: Deactivated successfully.
4月 14 18:58:04 PsiThinkpadArch systemd[1]: Started Thermal Daemon Service.

所以我修改了 thermald.service

# systemctl edit --full thermald.service
-----------------------------
[Unit]
Description=Thermal Daemon Service
ConditionVirtualization=no

[Service]
Type=dbus
SuccessExitStatus=2
BusName=org.freedesktop.thermald
ExecStart=/usr/bin/thermald --systemd --dbus-enable --adaptive --ignore-cpuid-check
Restart=on-failure

[Install]
WantedBy=multi-user.target
Alias=dbus-org.freedesktop.thermald.service

并且启动了他. 现在好像没问题了, 三个模式(powersave, balanced, performance)都可以正常工作, 而且 balanced 下 CPU 频率不会被限制在很低的水平. 就是不知道 thermald 是否真的和这台 Thinkpad 兼容 :expressionless:

可以用 override 的方式修改 service 文件,之后更新就不会覆盖你的修改了,见比如 How do I override or configure systemd services?
原来 systemctl edit 会生成一个 override 文件(用 --full 不会倒是),我都是自己创建的。。

thermald 听说能改善某些 intel cpu 的性能(不过我看到这个相关的都还是 tiger lake 的时代的说法,并且在我当时用的笔记本上没有明显的作用)

谢谢提醒, 我也只是试试 thermald (没想到真的有用), 维护的时候我会注意. Tiger Lake 已经很久了吗, 时间过得好快 lol.

在互联网冲浪中我发现了这个 https://askubuntu.com/questions/1520160/cpu-throttling-problems-on-my-thinkpad-x1-carbon-i7-10510u. 看起来是一个常见的问题 (对 Thinkpad 来说). 是否应该移动到笔记本模块?

我还在 thermald_daemon 的 github issues 中发现 Lenovo 应该有个自己的固件来调频, 而且 Lenovo 不支持 thermald (正如 这个问题的回答 所说). 所以这个问题应该是一个 Thinkpad 的问题 (或者联想的问题?), 我应该报告这个问题吗? :expressionless: