2

Is there a way to delete the old stats for a fresh start? I have set max CPU-speed to 950 MHz in file cpufrequtils. My issue is that this limitation is not in action when booting up, during which cpufrequtils is collecting data as can be seen from output: cpufreq stats: 1.20 GHz:27,27%. So after boot i would like to reset the stats to zero.

peter@peter-HP-Compaq-2510p:~$ cpufreq-info
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to cpufreq@vger.kernel.org, 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:~$ 

![enter image description here

Edit: Trying to follow advice given in answer, but there is no reset in folder:

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 Answers1

3

From: CPU frequency and voltage scaling statistics in the Linux(TM) kernel

<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

reset

Write-only attribute that can be used to reset the stat counters. This can be useful for evaluating system behaviour under different governors without the need for a reboot.

This should reset all the stats:

echo '1' | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/stats/reset

From: How to use cpufrequtils

cpufreq-set

Allows setting

-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 needs root privileges in order to work.

Look for this in your setup:

sudo cpufreq-set -u 950MGhz

and remove it. Or add this to your setup:

sudo cpufreq-set -u 1.20Ghz

From: HowTo CpuFrequencyScaling

GOVERNOR variable from /etc/default/cpufrequtils not taking effect

So, you configured the GOVERNOR variable in /etc/default/cpufrequtils and after reboot you notice by running cpufreq-info that the active governor is still "ondemand".

This may happen if you have laptop-mode-tools installed. laptop-mode configures the active governor via the following variables: BATT_CPU_GOVERNOR, LM_AC_CPU_GOVERNOR, NOLM_AC_CPU_GOVERNOR. You can override them to your liking in /etc/laptop-mode/laptop-mode.conf:

BATT_CPU_GOVERNOR=powersave
LM_AC_CPU_GOVERNOR=conservative
NOLM_AC_CPU_GOVERNOR=ondemand

From: Arch Linux CPU frequency scaling

Setting maximum and minimum frequencies

In rare cases, it may be necessary to manually set maximum and minimum frequencies.

To set the maximum clock frequency (clock_freq is a clock frequency with units: GHz, MHz):

sudo cpupower frequency-set -u clock_freq

To set the minimum clock frequency:

sudo cpupower frequency-set -d clock_freq

To set the CPU to run at a specified frequency:

sudo cpupower frequency-set -f clock_freq
  • Thanks. Directly after booting up, the percentage for 1.20 GHz is the highest. Then, for each cpufreq-info, it is sinking. That's why I would like to get rid of stats invoving data from startup, so I can better see how the max of 950 MHz works . Changed to userspace, but no obvious difference. – PeterEriksson Apr 27 '19 at 22:42
  • 1
    @PeterEriksson Almost all Ubuntu based laptops start at maximum frequency during the first minute and then speed governors are engaged. See: https://askubuntu.com/questions/1021748/set-cpu-governor-to-performance-in-18-04/1084727#1084727 – WinEunuuchs2Unix Apr 27 '19 at 22:48
  • Seems like cpufreq collects stats during boot, and that the set max CPU-speed is not yet activated. – PeterEriksson Apr 27 '19 at 22:53
  • The max is deliberatly set to 950 MHz. Fan not working. – PeterEriksson Apr 27 '19 at 22:59
  • @PeterEriksson I misunderstood the question at first. Check the first part of the answer now. Additionally a new fan can be as little as $20. – WinEunuuchs2Unix Apr 28 '19 at 00:47
  • See my edit in the question. So how can I get a reset-file? Actually, I really enjoy the silence that came with the no fan situation! – PeterEriksson Apr 28 '19 at 08:53
  • @PeterEriksson Try: echo '1' | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/stats/reset – WinEunuuchs2Unix Apr 28 '19 at 13:54
  • Problem seems to be that there is no file "reset" in the directory "stats". This is what happens: peter@peter-HP-Compaq-2510p:~$ echo '1' | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/stats/reset tee: '/sys/devices/system/cpu/cpu*/cpufreq/stats/reset': No such file or directory 1 – PeterEriksson Apr 28 '19 at 14:07
  • @PeterEriksson does the directory exist? ll /sys/devices/system/cpu/cpu0/cpufreq/stats/ – WinEunuuchs2Unix Apr 28 '19 at 14:09
  • Yes, and output from ls -lis edited into the question. Obviously, the reset-file isn't included in the installation of cpufreq. – PeterEriksson Apr 28 '19 at 14:15
  • @PeterEriksson I'll review the documentation again. – WinEunuuchs2Unix Apr 28 '19 at 14:23
  • After having removed and reinstalled cpufrequtils, there is still, even after reboot, no reset file in the stats directory. I'm on 32-bit 18.04.2 Xubuntu system. – PeterEriksson Apr 28 '19 at 15:29
  • I'm on Ubuntu 16.04 64-bit and do not even have a .../stats sub-directory at all. I've spent hours on this issue and will have to tap out... – WinEunuuchs2Unix Apr 28 '19 at 15:32
  • Tried installing cpufrequtils on my other hp 2510p which runs on 64-bit Ubuntu 18.04.02 LTS. This installation came with a reset file in stats and when executing echo '1' | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/stats/reset stats went to zero. So this issue must be about different distributions of cpufrequtils? – PeterEriksson Apr 28 '19 at 17:13
  • @PeterEriksson Yes the 32-bit versions have pretty much been abandoned. The on-line documentation I found was probably based on up-to-date modern 64-bit distributions. Good to know I wasn't going crazy trying to solve this problem :). Thanks for the update! – WinEunuuchs2Unix Apr 28 '19 at 17:36