我正在尝试将 CPU 最大频率设置为 提供的最大值scaling_available_frequencies
,但看起来内核只是忽略了我。
我的内核:
# uname -a
Linux valfenda 5.10.32-051032-generic #202104210836 SMP Wed Apr 21 13:18:19 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
但使用5.8也是一样的。
我的处理器是 AMD Ryzen 7 4700U,带有 Radeon Graphics,8 核。
# cpufreq-info -c0
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to [email protected], please.
analyzing CPU 0:
driver: acpi-cpufreq
CPUs which run at the same hardware frequency: 0
CPUs which need to have their frequency coordinated by software: 0
maximum transition latency: 4294.55 ms.
hardware limits: 1.40 GHz - 2.00 GHz
available frequency steps: 2.00 GHz, 1.70 GHz, 1.40 GHz
available cpufreq governors: conservative, ondemand, userspace, powersave, performance, schedutil
current policy: frequency should be within 1.40 GHz and 1.40 GHz.
The governor "performance" may decide which speed to use
within this range.
current CPU frequency is 1.40 GHz (asserted by call to hardware).
cpufreq stats: 2.00 GHz:0.05%, 1.70 GHz:0.04%, 1.40 GHz:99.91% (199)
注意这一行:frequency should be within 1.40 GHz and 1.40 GHz
。
我试过:
# cat scaling_available_frequencies
2000000 1700000 1400000
# cut -d' ' -f1 scaling_available_frequencies > scaling_max_freq
# cat scaling_max_freq
1400000
和:
# cpufreq-set -u2GHz
# cpufreq-info | ag 'current policy'
current policy: frequency should be within 1.40 GHz and 1.40 GHz.
current policy: frequency should be within 1.40 GHz and 1.40 GHz.
current policy: frequency should be within 1.40 GHz and 1.40 GHz.
current policy: frequency should be within 1.40 GHz and 1.40 GHz.
current policy: frequency should be within 1.40 GHz and 1.40 GHz.
current policy: frequency should be within 1.40 GHz and 1.40 GHz.
current policy: frequency should be within 1.40 GHz and 1.40 GHz.
current policy: frequency should be within 1.40 GHz and 1.40 GHz.
没有不同。
我的模块:
# lsmod
Module Size Used by
msr 16384 0
btrfs 1351680 0
blake2b_generic 20480 0
xor 24576 1 btrfs
raid6_pq 114688 1 btrfs
ufs 81920 0
qnx4 16384 0
hfsplus 110592 0
hfs 61440 0
minix 45056 0
ntfs 106496 0
msdos 20480 0
jfs 196608 0
xfs 1511424 0
rfcomm 81920 4
nf_conntrack_netlink 49152 0
xfrm_user 36864 1
xfrm_algo 16384 1 xfrm_user
xt_addrtype 16384 2
br_netfilter 28672 0
ccm 20480 6
xt_CHECKSUM 16384 1
xt_MASQUERADE 20480 4
xt_conntrack 16384 2
cmac 16384 5
algif_hash 16384 2
ipt_REJECT 16384 2
algif_skcipher 16384 2
nf_reject_ipv4 16384 1 ipt_REJECT
af_alg 32768 10 algif_hash,algif_skcipher
xt_tcpudp 20480 9
ip6table_mangle 16384 1
ip6table_nat 16384 1
iptable_mangle 16384 1
iptable_nat 16384 1
nf_nat 49152 3 ip6table_nat,iptable_nat,xt_MASQUERADE
nf_conntrack 147456 4 xt_conntrack,nf_nat,nf_conntrack_netlink,xt_MASQUERADE
nf_defrag_ipv6 24576 1 nf_conntrack
nf_defrag_ipv4 16384 1 nf_conntrack
nf_tables 208896 0
libcrc32c 16384 5 nf_conntrack,nf_nat,btrfs,nf_tables,xfs
nfnetlink 20480 3 nf_conntrack_netlink,nf_tables
ip6table_filter 16384 1
ip6_tables 32768 3 ip6table_filter,ip6table_nat,ip6table_mangle
iptable_filter 16384 1
bpfilter 16384 0
bridge 233472 1 br_netfilter
stp 16384 1 bridge
llc 16384 2 bridge,stp
bnep 24576 2
overlay 131072 0
joydev 28672 0
amdgpu 5988352 40
snd_hda_codec_realtek 139264 1
snd_hda_codec_generic 81920 1 snd_hda_codec_realtek
ledtrig_audio 16384 1 snd_hda_codec_generic
snd_hda_codec_hdmi 65536 1
snd_hda_intel 53248 5
iommu_v2 20480 1 amdgpu
iwlmvm 413696 0
snd_intel_dspcfg 28672 1 snd_hda_intel
soundwire_intel 40960 1 snd_intel_dspcfg
gpu_sched 40960 1 amdgpu
soundwire_generic_allocation 16384 1 soundwire_intel
soundwire_cadence 32768 1 soundwire_intel
ttm 102400 1 amdgpu
snd_acp3x_pdm_dma 16384 1
snd_hda_codec 147456 4 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec_realtek
mac80211 970752 1 iwlmvm
drm_kms_helper 233472 1 amdgpu
snd_hda_core 94208 5 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek
snd_hwdep 16384 1 snd_hda_codec
snd_acp3x_rn 16384 1
soundwire_bus 77824 3 soundwire_intel,soundwire_generic_allocation,soundwire_cadence
snd_soc_dmic 16384 1
libarc4 16384 1 mac80211
cec 53248 1 drm_kms_helper
edac_mce_amd 32768 0
snd_soc_core 282624 4 soundwire_intel,snd_acp3x_rn,snd_soc_dmic,snd_acp3x_pdm_dma
rc_core 57344 1 cec
i2c_algo_bit 16384 1 amdgpu
binfmt_misc 24576 1
btusb 57344 0
kvm_amd 102400 0
snd_seq_midi 20480 0
iwlwifi 376832 1 iwlmvm
snd_seq_midi_event 16384 1 snd_seq_midi
btrtl 24576 1 btusb
fb_sys_fops 16384 1 drm_kms_helper
snd_compress 28672 1 snd_soc_core
ac97_bus 16384 1 snd_soc_core
kvm 798720 1 kvm_amd
snd_pcm_dmaengine 16384 1 snd_soc_core
snd_rawmidi 36864 1 snd_seq_midi
btbcm 16384 1 btusb
syscopyarea 16384 1 drm_kms_helper
snd_pcm 118784 9 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,soundwire_intel,snd_compress,snd_soc_core,snd_hda_core,snd_acp3x_pdm_dma,snd_pcm_dmaengine
btintel 28672 1 btusb
crct10dif_pclmul 16384 1
nls_iso8859_1 16384 1
snd_seq 73728 2 snd_seq_midi,snd_seq_midi_event
sysfillrect 16384 1 drm_kms_helper
ghash_clmulni_intel 16384 0
bluetooth 651264 31 btrtl,btintel,btbcm,bnep,btusb,rfcomm
aesni_intel 372736 11
snd_seq_device 16384 3 snd_seq,snd_seq_midi,snd_rawmidi
snd_timer 40960 2 snd_seq,snd_pcm
crypto_simd 16384 1 aesni_intel
cryptd 24576 4 crypto_simd,ghash_clmulni_intel
sysimgblt 16384 1 drm_kms_helper
snd 94208 25 snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek,snd_timer,snd_compress,snd_soc_core,snd_pcm,snd_rawmidi
glue_helper 16384 1 aesni_intel
ecdh_generic 16384 2 bluetooth
cfg80211 843776 3 iwlmvm,iwlwifi,mac80211
soundcore 16384 1 snd
ecc 32768 1 ecdh_generic
input_leds 16384 0
snd_rn_pci_acp3x 20480 0
rapl 20480 0
ccp 102400 1 kvm_amd
snd_pci_acp3x 20480 0
serio_raw 20480 0
hp_wmi 20480 0
sparse_keymap 16384 1 hp_wmi
efi_pstore 16384 0
wmi_bmof 16384 0
hid_multitouch 28672 0
k10temp 16384 0
ucsi_acpi 16384 0
typec_ucsi 36864 1 ucsi_acpi
typec 53248 1 typec_ucsi
mac_hid 16384 0
hp_accel 28672 0
lis3lv02d 24576 1 hp_accel
hp_wireless 16384 0
acpi_tad 20480 0
sch_fq_codel 20480 2
cuse 16384 3
parport_pc 45056 0
ppdev 24576 0
lp 20480 0
parport 65536 3 parport_pc,lp,ppdev
drm 548864 20 gpu_sched,drm_kms_helper,amdgpu,ttm
ip_tables 32768 3 iptable_filter,iptable_nat,iptable_mangle
x_tables 45056 12 ip6table_filter,xt_conntrack,iptable_filter,xt_tcpudp,xt_addrtype,xt_CHECKSUM,ip6_tables,ipt_REJECT,ip_tables,ip6table_mangle,xt_MASQUERADE,iptable_mangle
autofs4 45056 2
hid_generic 16384 0
rtsx_pci_sdmmc 28672 0
crc32_pclmul 16384 0
nvme 45056 4
ahci 40960 0
rtsx_pci 94208 1 rtsx_pci_sdmmc
i2c_piix4 28672 0
xhci_pci 20480 0
libahci 36864 1 ahci
nvme_core 122880 6 nvme
xhci_pci_renesas 20480 1 xhci_pci
wmi 32768 2 hp_wmi,wmi_bmof
video 49152 0
i2c_hid 32768 0
hid 135168 3 i2c_hid,hid_multitouch,hid_generic
我见过其他类似的问题,但没有令人满意的答案。
答案1
基本上我有一个最新的 RHEL-9.2 运行在:
- 计算机:Dell XPS L412Z(又名 14Z - c. 2011)
- 红帽企业 Linux 9
- kernel-5.14.0-162.23.1.el9_1.x86_64 - 最近
dnf update
- 处理器:Intel(R) Core(TM) i7-2640M CPU @ 2.80GHz
- 电池组:DELL YMYF6252(克隆?)
我遇到的问题和你的一样...
即,无论我做什么,我的计算机都卡在 798 MHz 下运行,即使我加载 CPU,4 个 CPU 中的每一个都在运行while true; do true; done
,但仍顽固地保持在 798 MHz。
我尝试了所有cpufreq governors
:保守的按需用户空间powersave性能schedutil
即使重启也没有效果。但我确实找到了一个诡异的解决方法。
# cpupower -c 0 frequency-info ↲
analyzing CPU 0:
driver: intel_cpufreq
CPUs which run at the same hardware frequency: 0
CPUs which need to have their frequency coordinated by software: 0
maximum transition latency: 20.0 us
hardware limits: 800 MHz - 3.50 GHz
available cpufreq governors: conservative ondemand userspace powersave performance schedutil
current policy: frequency should be within 800 MHz and 3.50 MHz.
The governor "performance" may decide which speed to use
within this range.
current CPU frequency: Unable to call hardware
current CPU frequency: 798 MHz (asserted by call to kernel)
boost state support:
Supported: yes
Active: yes
3300 MHz max turbo 4 active cores
3300 MHz max turbo 3 active cores
3300 MHz max turbo 2 active cores
3500 MHz max turbo 1 active cores
风扇顽固地保持低速运转,CPU/核心温度在+50.0°C左右:
# sensors ↲
...
Package id 0: +54.0°C (high = +86.0°C, crit = +100.0°C)
修复?
- 从交流电源适配器上拔下笔记本电脑的插头...
突然,4 ×while true; do true; done &
负载笔记本电脑的风扇加速了,我发现 CPU 现在运行在:2.72 GHz!
现在CPU和风扇都加速了:
# cpupower -c 0 frequency-info ↲
...
current CPU frequency: 2.82 GHz (asserted by call to kernel)
然后我插入交流电源适配器,戴尔笔记本电脑运行良好。诡异的
笔记本电脑随后恢复为卡在 798 MHz。拔掉电源并重新插入电源确实解决了这个问题。但是笔记本电脑使用交流电源适配器暂停/恢复(或者可能是电源循环)拔掉插头似乎解决了这个问题。
对于我的笔记本电脑来说,这是一个足够好的解决方法。但看起来有一个类似的潜在错误已经存在了几年......例如。
其他地方有类似问题:
- 2021 年:linux:无法使用 cpupower 设置 cpu 频率调节器
- 2021 年:linux:无法使用 cpupower 设置 cpu 频率调节器(ACPI 故障)
- 2018:已解决 - CPU 频率停留在 800MHz
- 2018:已解决 - Dell XPS 9550 CPU 倍频卡在 8
- 2017年:cpufrequtils 显示我的 CPU 可以以更高的频率执行...为什么我不能达到最大频率?
- 2017年:奇怪的 cpufreq 缩放问题:无论调速器如何,最大 cpufreq 在唤醒时逐渐下降- 2017 年:为什么即使我的应用程序(利用 CPU 资源)滞后,我的 CPU 也无法发挥其最大潜力?
- 2012年:即使在负载下,处理器仍保持降频
- 2011年:cpufreq 策略表现得很奇怪,当前策略最大值受到限制
答案2
以下将所有 cpu 核心设置为最大频率。您可能需要安装实用程序 cpupower。
cd /sys/devices/system/cpu/
sudo cpupower frequency-set -g performance