[英]How to set specific cpu frequency when using intel_pstate
When I am using intel_pstate, I found that I can not change the cpu frequency with command:当我使用 intel_pstate 时,我发现我无法使用命令更改 cpu 频率:
sudo cpupower frequency-set -f SomeValue
I know the reason is that intel_pstate's governors (powersave and performance) don't support changing frequency manually.我知道原因是 intel_pstate 的调节器(省电和性能)不支持手动更改频率。 Also I tried to write frequency value directly to the file /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq .
我还尝试将频率值直接写入文件/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq 。 But it says I'm changing a readonly file.
但它说我正在更改一个只读文件。
So is there a way to change a core's frequency when using intel_pstate driver?那么在使用 intel_pstate 驱动程序时有没有办法改变内核的频率?
The intel_pstate
driver running in one of the active modes doesn't allow you to set a particular frequency directly ( cpupower frequency-set -f
), but you can change the maximum and minimum frequencies the driver is allowed to set as follows:在其中一种活动模式下运行的
intel_pstate
驱动程序不允许您直接设置特定频率 ( cpupower frequency-set -f
),但您可以更改允许驱动程序设置的最大和最小频率,如下所示:
With cpupower you can use:使用 cpupower,您可以使用:
cpupower frequency-set -u 3000mhz
… to set the maximum frequency for all cores. …设置所有内核的最大频率。 To set minimum frequency you can use
要设置最小频率,您可以使用
cpupower frequency-set -d 3000mhz
These commands require root privileges (executed with sudo
).这些命令需要 root 权限(使用
sudo
执行)。
In this example, the desired frequency 3000 MHz is applied to all cores.在此示例中,将所需频率 3000 MHz 应用于所有内核。 The actual frequency would be the closest supported frequency that is larger than (if possible) to the desired frequency.
实际频率将是大于(如果可能)所需频率的最接近的支持频率。 The actual active range of frequencies and current core frequency can determined from
cpupower frequency-info
.实际有效频率范围和当前核心频率可以从
cpupower frequency-info
确定。
Some processors support per-core frequency domains.一些处理器支持每核频域。 You can specify a particular core or a set of cores with the
-c
option for which you want to change the frequency range.您可以使用
-c
选项指定要更改频率范围的特定内核或一组内核。
Yes, there is.就在这里。 Before setting the frequency, first set intel_pstate to passive .
在设置频率之前,首先将 intel_pstate 设置为被动。 That enables setting the governor to userspace .
这可以将调控器设置为userspace 。 Then set the governor to userspace .
然后将调控器设置为userspace 。 My script for this purpose:
我为此目的的脚本:
#!/bin/bash
# Rig4TopSpeed.sh
UPPER=4200MHz
LOWER=4200MHz
echo passive | sudo tee /sys/devices/system/cpu/intel_pstate/status
sudo cpupower idle-set -E
sudo cpupower frequency-set -g userspace
sudo cpupower frequency-set -u $UPPER
sudo cpupower frequency-set -d $UPPER
sudo cpupower frequency-set -f $UPPER
sudo cpupower frequency-info
echo
sudo turbostat --num_iterations 1 --interval 2 2>/dev/shm/turbostat.stderr
echo
grep -i "cpufreq" /dev/shm/turbostat.stderr
echo
grep -i "frequency" /dev/shm/turbostat.stderr
echo
grep -i "max turbo" /dev/shm/turbostat.stderr
echo
inxi -C|cat
echo
grep "cpu MHz" /proc/cpuinfo
sleep 3
The sleep at the bottom gives me time to look at the results before the console window self-closes when run from a GUI menu.底部的睡眠让我有时间在控制台 window 从 GUI 菜单运行时自动关闭之前查看结果。
Note that if your CPU has HWP and it is active, then the CPU takes your settings as advice.请注意,如果您的 CPU 具有 HWP 并且它处于活动状态,那么 CPU 会将您的设置作为建议。 Idle and hot CPU's will have other clock rates.
空闲和热 CPU 将有其他时钟频率。
Advice: Never set the fixed value to higher than what turbostat reports the CPU can do with all cores active.建议:切勿将固定值设置为高于 turbostat 报告的 CPU 在所有内核处于活动状态时可以执行的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.