我使用的笔记本电脑的冷却系统很差,所以我的 CPU 有时会达到非常高的温度,Linux 内核能够调节 cpu 时钟来冷却它,正如我在 dmesg 中看到的:
[22612.245243] CPU3: Core temperature above threshold, cpu clock throttled (total events = 617268)
...
[22612.257307] CPU3: Core temperature/speed normal
etc
最近,我安装了 FreeBSD 来玩它,我注意到它始终以全速使用 CPU,即使我设置powerd
为-a hiadaptive -b adaptive -i 85 -r 60 -p 100
,所以在一些使用后 CPU 温度高于正常值,FreeBSD 只是重新启动而不是节流。我也尝试过使用 C 状态,但没有帮助。
我如何配置它以获得 Linux 行为?
答案1
我遇到了类似的问题,我的防火墙(一台旧笔记本电脑)会由于 CPU 过热而关闭。我使用以下步骤解决了该问题,对 pfSense 防火墙有效:
1)下载FreeBSDcpu速度.sh 文件来自 GitHub,作者:dreamcat4
2)创建文件cpu速度.sh,并通过 pfSense 管理界面,使用 Diagnostics >> Edit File 粘贴上一步中链接的源内容
3) 启用文件执行cpu速度.sh在 fSense 管理界面中,使用 Diagnostics >> Command Prompt 和命令$ chmod +x /[path_to_file]/cpu-speed.sh
4) 通过$ sysctl dev.cpu.0.freq_levels
在命令提示符中运行来检查可用的 CPU 频率
4)运行文件cpu速度.sh[valid_CPU_frq] 使用命令$ cd /[path_to_file] && ./cpu-speed.sh [valid_CPU_frq]
5) 使用命令检查当前(新)CPU 频率$ sysctl dev.cpu.0.freq
6)完成。
我为我的 CPU 选择了可接受的最低 CPU 核心频率,并且能够将我的 CPU 的 CPU 核心温度从 +90 C 永久降低到 < 60 C。
编辑: 为了避免将来出现死链接,请找到 dreamcat4 的代码(如上面链接)的文件cpu速度.sh以下:
#!/bin/sh
#
# cpu-speed:
# Requirements - be the root user, FreeBSD 9.2 or higher.
#
# Get or set the CPU frequency. This command with no arguments will
# print the current CPU frequency. CPU may be idling at it's lowest speed.
#
# This command takes 1 optional argument - new MAX cpu freq (in Mhz).
# expressed as an integer number. e.g. "cpu 800" - set max freq 800 Mhz.
# This MAX figure is the new max frequency it is allowed to clock up to.
#
# Number is rounded off to the nearest allowed frequency multiplier.
#
show_all_cpu_sysctl_settings()
{
# Most FreeBSD kernel settings are read-only. Some may look like duplicates.
# Very few are read-write (so we use powerd). Some CPU settings depend on the CPU family.
# This command should reveal all the CPU-related key names:
sysctl - a | grep - i cpu
}
set_cpu_speed()
{
# To change the max clock, we must restart the "powerd" rc.d service
# with new cmdline arguments. "man powerd" for more information.
if ["$(id -u)" = "0"]; then
if [!"$(grep "cpuspeed" " / etc / rc.conf")"]; then
echo "" >> "/etc/rc.conf"
echo "powerd_enable=\"YES\"" >> "/etc/rc.conf"
# make the cmdline argument to -M flag a txt substitution with the txt file "/etc/cpuspeed"
echo "powerd_flags=\"-M \$(cat /etc/cpuspeed)\"" >> "/etc/rc.conf"
fi
if ["$1"]; then
# write our new cpu speed to the txt file "/etc/cpuspeed"
echo "$1" > / etc / cpuspeed
# restart powerd daemon to read the new cpu speed
/ etc / rc.d / powerd restart > / dev / null
fi
fi
}
print_current_cpu_freq()
{
# Report back the current cpu frequency for core "0"
sysctl dev.cpu.0.freq
}
show_possible_cpu_speeds()
{
# Show a list of all possible cpu frequency steps for core "0"
sysctl dev.cpu.0.freq_levels
}
main()
{
set_cpu_speed "$@";
sleep 1; # give it a chance to update before we check the new value
print_current_cpu_freq;
show_possible_cpu_speeds;
}
# Entry point
main "$@"