简体   繁体   English

使用 intel_pstate 时如何设置特定的 cpu 频率

[英]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.

相关问题 如何为基于 Intel 的最新 Mac OS 创建具有特定/仅本机架构的存档构建 - How to create Archive build with Specific / Native Only Architecture for Intel based Latest Mac OS 使 GCP 中 DLP 的 FPE 算法在编码时避免使用特定的字符集 - make FPE algorithm of DLP in GCP refrain from using a specific set of characters when encoding 使用会话/cookie 进行持久性时,如何在 Firebase 中设置“currentUser”? - How to set the `currentUser` in Firebase when using sessions/cookies for persistence? 如何强制./configure 使用 intel oneAPI 编译器? - How to force ./configure to use intel oneAPI compilers? 使用aws-amplify时如何设置cookie过期时间为30分钟? - How to set the cookie expiration time to 30 minutes when using aws-amplify? 如何在特定事件发生后使用正则表达式获取字符串的特定部分? - How to get a specific part of a string using Regex after specific occurances? Apple Silicon Chip 如何在没有 Rosetta 的情况下支持基于 Intel 的 JDK-8? - How does Apple Silicon Chip support Intel based JDK-8 without rosetta? 如何使用无服务器框架为 API 网关设置描述? - How to set a description for an API Gateway using the Serverless Framework? 如何在批处理脚本中启动 Intel Power Gadget? - How to start Intel Power Gadget in Batch Script? 如何使用 flutter 和 dart 从 Cloud Firestore 检索特定数据? - how to retrieve specific data from Cloud Firestore using flutter and dart?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM