如何在内核为 5.17+ 的 Ubuntu 20.04 上安装 cpupower

如何在内核为 5.17+ 的 Ubuntu 20.04 上安装 cpupower

我正在测试新的amd-pstate驱动程序,我已经通过以下方式安装了最新的内核 5.18ppa:tuxinvader/lts-主线,改变了一些启动选项,一切都运行正常。

不幸的是,当我运行命令时cpupower,我得到了:

WARNING: cpupower not found for kernel 5.18.5-051805

  You may need to install the following packages for this specific kernel:
    linux-tools-5.18.5-051805-generic
    linux-cloud-tools-5.18.5-051805-generic

  You may also want to install one of the following packages to keep up to date:
    linux-tools-generic
    linux-cloud-tools-generic

linux-tools-generic已经安装但找不到linux-tools-5.18.5-051805-generic,我的系统上的最新版本是linux-tools-5.13.0-25-generic。我找不到安装的方法cpupower

答案1

如果您无法获取最新的 cpupower,或者即使您可以获取,您也可以使用基本命令来更改 CPU 频率调节驱动程序的运行参数:

例子:

看看有哪些可用资源:

doug@s19:~/kernel/linux$ grep . /sys/devices/system/cpu/cpu0/cpufreq/*
/sys/devices/system/cpu/cpu0/cpufreq/affected_cpus:0
/sys/devices/system/cpu/cpu0/cpufreq/base_frequency:4100000
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq:4800000
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq:800000
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_transition_latency:20000
/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences:default performance balance_performance balance_power power
/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference:balance_performance
/sys/devices/system/cpu/cpu0/cpufreq/related_cpus:0
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors:conservative ondemand userspace powersave performance schedutil
/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq:800000
/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver:intel_cpufreq
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor:schedutil
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq:4800000
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq:800000
/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed:<unsupported>

好的,我宁愿使用按需 CPU 频率缩放调节器,因此更改它然后检查它:

doug@s19:~/kernel/linux$ echo ondemand | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
ondemand
doug@s19:~/kernel/linux$ grep . /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor:ondemand
/sys/devices/system/cpu/cpu10/cpufreq/scaling_governor:ondemand
/sys/devices/system/cpu/cpu11/cpufreq/scaling_governor:ondemand
/sys/devices/system/cpu/cpu1/cpufreq/scaling_governor:ondemand
/sys/devices/system/cpu/cpu2/cpufreq/scaling_governor:ondemand
/sys/devices/system/cpu/cpu3/cpufreq/scaling_governor:ondemand
/sys/devices/system/cpu/cpu4/cpufreq/scaling_governor:ondemand
/sys/devices/system/cpu/cpu5/cpufreq/scaling_governor:ondemand
/sys/devices/system/cpu/cpu6/cpufreq/scaling_governor:ondemand
/sys/devices/system/cpu/cpu7/cpufreq/scaling_governor:ondemand
/sys/devices/system/cpu/cpu8/cpufreq/scaling_governor:ondemand
/sys/devices/system/cpu/cpu9/cpufreq/scaling_governor:ondemand

我想限制我的最大 CPU 频率,因此更改它并检查它:

doug@s19:~/kernel/linux$ echo 4400000 | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq
4400000
doug@s19:~/kernel/linux$ grep . /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq:4400000
/sys/devices/system/cpu/cpu10/cpufreq/scaling_max_freq:4400000
/sys/devices/system/cpu/cpu11/cpufreq/scaling_max_freq:4400000
/sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq:4400000
/sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq:4400000
/sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq:4400000
/sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq:4400000
/sys/devices/system/cpu/cpu5/cpufreq/scaling_max_freq:4400000
/sys/devices/system/cpu/cpu6/cpufreq/scaling_max_freq:4400000
/sys/devices/system/cpu/cpu7/cpufreq/scaling_max_freq:4400000
/sys/devices/system/cpu/cpu8/cpufreq/scaling_max_freq:4400000
/sys/devices/system/cpu/cpu9/cpufreq/scaling_max_freq:4400000

我想知道频率是否真的受到限制?对 CPU 施加重负载,然后检查:

doug@s19:~/kernel/linux$ grep . /sys/devices/system/cpu/cpu*/cpufreq

/scaling_cur_freq
/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq:4399985
/sys/devices/system/cpu/cpu10/cpufreq/scaling_cur_freq:4400002
/sys/devices/system/cpu/cpu11/cpufreq/scaling_cur_freq:4400022
/sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq:4399980
/sys/devices/system/cpu/cpu2/cpufreq/scaling_cur_freq:4400004
/sys/devices/system/cpu/cpu3/cpufreq/scaling_cur_freq:4400007
/sys/devices/system/cpu/cpu4/cpufreq/scaling_cur_freq:4399988
/sys/devices/system/cpu/cpu5/cpufreq/scaling_cur_freq:4400017
/sys/devices/system/cpu/cpu6/cpufreq/scaling_cur_freq:4399985
/sys/devices/system/cpu/cpu7/cpufreq/scaling_cur_freq:4400003
/sys/devices/system/cpu/cpu8/cpufreq/scaling_cur_freq:4400006
/sys/devices/system/cpu/cpu9/cpufreq/scaling_cur_freq:4399997

我想回到最大 CPU 频率:

doug@s19:~/kernel/linux$ echo 4800000 | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq
4800000
doug@s19:~/kernel/linux$ grep . /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq:4800002
/sys/devices/system/cpu/cpu10/cpufreq/scaling_cur_freq:4799995
/sys/devices/system/cpu/cpu11/cpufreq/scaling_cur_freq:4799998
/sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq:4800010
/sys/devices/system/cpu/cpu2/cpufreq/scaling_cur_freq:4800016
/sys/devices/system/cpu/cpu3/cpufreq/scaling_cur_freq:4799994
/sys/devices/system/cpu/cpu4/cpufreq/scaling_cur_freq:4799987
/sys/devices/system/cpu/cpu5/cpufreq/scaling_cur_freq:4800012
/sys/devices/system/cpu/cpu6/cpufreq/scaling_cur_freq:4800000
/sys/devices/system/cpu/cpu7/cpufreq/scaling_cur_freq:4799985
/sys/devices/system/cpu/cpu8/cpufreq/scaling_cur_freq:4800022
/sys/devices/system/cpu/cpu9/cpufreq/scaling_cur_freq:4799989

答案2

在 AWS Ubuntu 20.04 上,安装命令略有不同:使用sudo apt install -y linux-tools-5.13.0-1031-aws linux-tools-common

通常,安装sudo apt-get install -y linux-tools-common然后尝试cpupower在命令行上运行,会使程序显示运行所需安装的内容cpupower

sudo apt-get install cpufrequtils

答案3

如何安装 cpupower:

# apt install linux-tools-$(uname -r) linux-cloud-tools-$(uname -r)

相关内容