动态电压和频率缩放 API

发布于 2024-12-29 04:56:35 字数 50 浏览 4 评论 0原文

Linux 上是否存在 API(C 语言)来允许进程动态更改其运行的内核的电压或频率?

Does an API (in C) exist on Linux to allow a process to dynamically change the voltage or the frequency of the core it runs on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

倾城泪 2025-01-05 04:56:35

可能有这样的库,但即使没有,您也可以随时打开 /sys/devices/system/cpu 下配置 CPU 行为的文件。
查看 /sys/devices/system/cpu/cpuX/cpufreq 下的文件。

There might be such a library, but even if it doesn't, you can always open the files under /sys/devices/system/cpu that configure the behavior of the CPU.
Take a look to the files under /sys/devices/system/cpu/cpuX/cpufreq .

诗酒趁年少 2025-01-05 04:56:35

您可以通过写入以下内容来更改频率电压对:
/sys/devices/system/cpu/cpu%d/cpufreq/scaling_setspeed 文件。每个硬件线程都有一个文件。但是,您只能更改整个芯片(所有内核)的频率。您可以从以下位置找到可用频率:
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies

如果您没有此文件夹,请检查您的处理器是否具有可用的增强型 Intel SpeedStep® 技术。如果有,请进入 BIOS 并启用它,您将看到该文件夹​​。
另一件事,您可能需要启用/安装 cpufreq 模块。

希望它对某人有所帮助,因为原来的位置已经很旧了。

You can change the frequency voltage pair by writing to:
/sys/devices/system/cpu/cpu%d/cpufreq/scaling_setspeed file. There is a file for each hardware thread. However, you can only change the frequency for the entire chip (all the cores). You can find the available frequencies from:
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies

If you do not have this folder, check if your processor has Enhanced Intel SpeedStep® Technology available. If it has, go to the BIOS and enable it and you will see the folder.
One more thing, you might need to enable/install the cpufreq module.

Hope it helps someone since the original position is old.

眼藏柔 2025-01-05 04:56:35

CPU 动态电压频率调节示例:

# See availables operation performance points
cat /sys/class/devices/system/cpu/cpu0/scaling_available_frequencies
384000 460800 600000 672000 768000 864000 960000 1248000 1344000 1478400 1555200

# See current core frequency
cat /sys/devices/system/cpu/cpu0/scaling_cur_freq
384000

# See current core voltage
cat /sys/class/regulator/regulator.3/microvolts
785000

# Change CPU speed to 1248000 MHz
echo 1248000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 1248000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq

cat /sys/devices/system/cpu/cpu0/scaling_cur_freq
1248000

cat /sys/class/regulator/regulator.3/microvolts
980000

CPU Dynamic Voltage-Frequency Scaling Example:

# See availables operation performance points
cat /sys/class/devices/system/cpu/cpu0/scaling_available_frequencies
384000 460800 600000 672000 768000 864000 960000 1248000 1344000 1478400 1555200

# See current core frequency
cat /sys/devices/system/cpu/cpu0/scaling_cur_freq
384000

# See current core voltage
cat /sys/class/regulator/regulator.3/microvolts
785000

# Change CPU speed to 1248000 MHz
echo 1248000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 1248000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq

cat /sys/devices/system/cpu/cpu0/scaling_cur_freq
1248000

cat /sys/class/regulator/regulator.3/microvolts
980000
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文