有没有办法删除旧统计数据以便重新开始?我在文件中将最大 CPU 速度设置为 950 MHz cpufrequtils
。我的问题是,启动时此限制不起作用,在此期间cpufrequtils
正在收集数据,如输出所示:cpufreq stats: 1.20 GHz:27,27%
。因此,启动后我想将统计数据重置为零。
peter@peter-HP-Compaq-2510p:~$ cpufreq-info
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to [email protected], please.
analyzing CPU 0:
driver: acpi-cpufreq
CPUs which run at the same hardware frequency: 0
CPUs which need to have their frequency coordinated by software: 0
maximum transition latency: 10.0 us.
hardware limits: 800 MHz - 1.20 GHz
available frequency steps: 1.20 GHz, 1.07 GHz, 933 MHz, 800 MHz
available cpufreq governors: conservative, ondemand, userspace, powersave, performance
current policy: frequency should be within 800 MHz and 950 MHz.
The governor "ondemand" may decide which speed to use
within this range.
current CPU frequency is 933 MHz.
cpufreq stats: 1.20 GHz:27,27%, 1.07 GHz:0,48%, 933 MHz:47,91%, 800 MHz:24,34% (1449)
analyzing CPU 1:
driver: acpi-cpufreq
CPUs which run at the same hardware frequency: 1
CPUs which need to have their frequency coordinated by software: 1
maximum transition latency: 10.0 us.
hardware limits: 800 MHz - 1.20 GHz
available frequency steps: 1.20 GHz, 1.07 GHz, 933 MHz, 800 MHz
available cpufreq governors: conservative, ondemand, userspace, powersave, performance
current policy: frequency should be within 800 MHz and 950 MHz.
The governor "ondemand" may decide which speed to use
within this range.
current CPU frequency is 933 MHz.
cpufreq stats: 1.20 GHz:30,29%, 1.07 GHz:0,29%, 933 MHz:51,91%, 800 MHz:17,52% (763)
peter@peter-HP-Compaq-2510p:~$
编辑:尝试按照答案中给出的建议,但文件夹中没有重置:
peter@peter-HP-Compaq-2510p:~$ cd /sys/devices/system/cpu/cpu0/cpufreq/stats
peter@peter-HP-Compaq-2510p:/sys/devices/system/cpu/cpu0/cpufreq/stats$ ls -l
total 0
-r--r--r-- 1 root root 4096 apr 28 09:46 time_in_state
-r--r--r-- 1 root root 4096 apr 28 09:46 total_trans
-r--r--r-- 1 root root 4096 apr 28 09:46 trans_table
peter@peter-HP-Compaq-2510p:/sys/devices/system/cpu/cpu0/cpufreq/stats$ dir
time_in_state total_trans trans_table
peter@peter-HP-Compaq-2510p:/sys/devices/system/cpu/cpu0/cpufreq/stats$
答案1
从:Linux(TM) 内核中的 CPU 频率和电压调整统计数据
<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # ls -l
total 0
drwxr-xr-x 2 root root 0 May 14 16:06 .
drwxr-xr-x 3 root root 0 May 14 15:58 ..
--w------- 1 root root 4096 May 14 16:06 reset
-r--r--r-- 1 root root 4096 May 14 16:06 time_in_state
-r--r--r-- 1 root root 4096 May 14 16:06 total_trans
-r--r--r-- 1 root root 4096 May 14 16:06 trans_table
重置
只写属性,可用于重置统计计数器。这对于评估不同调节器下的系统行为非常有用,无需重新启动。
这将重置所有统计数据:
echo '1' | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/stats/reset
cpu频率设置
允许设置
-d minimum frequency,
-u maximum frequency,
-f specific frequency (userspace governor must be set first) and
-g governor on a
-c specific CPU.
cpufreq-set
需要 root 权限才能工作。
在你的设置中寻找这个:
sudo cpufreq-set -u 950MGhz
并将其删除。或者将其添加到您的设置中:
sudo cpufreq-set -u 1.20Ghz
/etc/default/cpufrequtils 中的 GOVERNOR 变量未生效
因此,您在 /etc/default/cpufrequtils 中配置了 GOVERNOR 变量,并且在重启后通过运行 cpufreq-info 您注意到活动调控器仍然处于“按需”状态。
如果您安装了 laptop-mode-tools,则可能会发生这种情况。laptop-mode 通过以下变量配置活动调节器:BATT_CPU_GOVERNOR、LM_AC_CPU_GOVERNOR、NOLM_AC_CPU_GOVERNOR。您可以在 /etc/laptop-mode/laptop-mode.conf 中根据自己的喜好覆盖它们:
BATT_CPU_GOVERNOR=powersave
LM_AC_CPU_GOVERNOR=conservative
NOLM_AC_CPU_GOVERNOR=ondemand
设置最大和最小频率
在极少数情况下,可能需要手动设置最大和最小频率。
设置最大时钟频率(clock_freq 是时钟频率,单位为:GHz、MHz):
sudo cpupower frequency-set -u clock_freq
要设置最小时钟频率:
sudo cpupower frequency-set -d clock_freq
要设置 CPU 以指定频率运行:
sudo cpupower frequency-set -f clock_freq