2020-03-03 13:52:06 +00:00
|
|
|
.. SPDX-License-Identifier: GPL-2.0
|
2005-05-25 21:43:56 +00:00
|
|
|
|
2020-03-03 13:52:06 +00:00
|
|
|
==========================================
|
|
|
|
General Description of sysfs CPUFreq Stats
|
|
|
|
==========================================
|
2005-05-25 21:43:56 +00:00
|
|
|
|
2020-03-03 13:52:06 +00:00
|
|
|
information for users
|
2005-05-25 21:43:56 +00:00
|
|
|
|
|
|
|
|
2020-03-03 13:52:06 +00:00
|
|
|
Author: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
|
2005-05-25 21:43:56 +00:00
|
|
|
|
2020-03-03 13:52:06 +00:00
|
|
|
.. Contents
|
2005-05-25 21:43:56 +00:00
|
|
|
|
2020-03-03 13:52:06 +00:00
|
|
|
1. Introduction
|
|
|
|
2. Statistics Provided (with example)
|
|
|
|
3. Configuring cpufreq-stats
|
2005-05-25 21:43:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
1. Introduction
|
2020-03-03 13:52:06 +00:00
|
|
|
===============
|
2005-05-25 21:43:56 +00:00
|
|
|
|
2007-05-09 05:35:06 +00:00
|
|
|
cpufreq-stats is a driver that provides CPU frequency statistics for each CPU.
|
2006-10-03 20:55:17 +00:00
|
|
|
These statistics are provided in /sysfs as a bunch of read_only interfaces. This
|
|
|
|
interface (when configured) will appear in a separate directory under cpufreq
|
2005-05-25 21:43:56 +00:00
|
|
|
in /sysfs (<sysfs root>/devices/system/cpu/cpuX/cpufreq/stats/) for each CPU.
|
|
|
|
Various statistics will form read_only files under this directory.
|
|
|
|
|
|
|
|
This driver is designed to be independent of any particular cpufreq_driver
|
|
|
|
that may be running on your CPU. So, it will work with any cpufreq_driver.
|
|
|
|
|
|
|
|
|
|
|
|
2. Statistics Provided (with example)
|
2020-03-03 13:52:06 +00:00
|
|
|
=====================================
|
2005-05-25 21:43:56 +00:00
|
|
|
|
|
|
|
cpufreq stats provides following statistics (explained in detail below).
|
2020-03-03 13:52:06 +00:00
|
|
|
|
2005-05-25 21:43:56 +00:00
|
|
|
- time_in_state
|
|
|
|
- total_trans
|
|
|
|
- trans_table
|
|
|
|
|
2017-01-06 05:38:05 +00:00
|
|
|
All the statistics will be from the time the stats driver has been inserted
|
|
|
|
(or the time the stats were reset) to the time when a read of a particular
|
|
|
|
statistic is done. Obviously, stats driver will not have any information
|
|
|
|
about the frequency transitions before the stats driver insertion.
|
2005-05-25 21:43:56 +00:00
|
|
|
|
2020-03-03 13:52:06 +00:00
|
|
|
::
|
|
|
|
|
|
|
|
<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**
|
|
|
|
|
2016-11-07 18:02:23 +00:00
|
|
|
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.
|
|
|
|
|
2020-03-03 13:52:06 +00:00
|
|
|
- **time_in_state**
|
|
|
|
|
2005-05-25 21:43:56 +00:00
|
|
|
This gives the amount of time spent in each of the frequencies supported by
|
|
|
|
this CPU. The cat output will have "<frequency> <time>" pair in each line, which
|
|
|
|
will mean this CPU spent <time> usertime units of time at <frequency>. Output
|
2020-03-03 13:52:06 +00:00
|
|
|
will have one line for each of the supported frequencies. usertime units here
|
2005-05-25 21:43:56 +00:00
|
|
|
is 10mS (similar to other time exported in /proc).
|
|
|
|
|
2020-03-03 13:52:06 +00:00
|
|
|
::
|
2005-05-25 21:43:56 +00:00
|
|
|
|
2020-03-03 13:52:06 +00:00
|
|
|
<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat time_in_state
|
|
|
|
3600000 2089
|
|
|
|
3400000 136
|
|
|
|
3200000 34
|
|
|
|
3000000 67
|
|
|
|
2800000 172488
|
2005-05-25 21:43:56 +00:00
|
|
|
|
2020-03-03 13:52:06 +00:00
|
|
|
|
|
|
|
- **total_trans**
|
|
|
|
|
|
|
|
This gives the total number of frequency transitions on this CPU. The cat
|
2005-05-25 21:43:56 +00:00
|
|
|
output will have a single count which is the total number of frequency
|
|
|
|
transitions.
|
|
|
|
|
2020-03-03 13:52:06 +00:00
|
|
|
::
|
|
|
|
|
|
|
|
<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat total_trans
|
|
|
|
20
|
|
|
|
|
|
|
|
- **trans_table**
|
2005-05-25 21:43:56 +00:00
|
|
|
|
|
|
|
This will give a fine grained information about all the CPU frequency
|
|
|
|
transitions. The cat output here is a two dimensional matrix, where an entry
|
2020-03-03 13:52:06 +00:00
|
|
|
<i,j> (row i, column j) represents the count of number of transitions from
|
2018-10-29 07:17:40 +00:00
|
|
|
Freq_i to Freq_j. Freq_i rows and Freq_j columns follow the sorting order in
|
|
|
|
which the driver has provided the frequency table initially to the cpufreq core
|
|
|
|
and so can be sorted (ascending or descending) or unsorted. The output here
|
|
|
|
also contains the actual freq values for each row and column for better
|
|
|
|
readability.
|
2005-05-25 21:43:56 +00:00
|
|
|
|
2017-11-07 08:09:29 +00:00
|
|
|
If the transition table is bigger than PAGE_SIZE, reading this will
|
|
|
|
return an -EFBIG error.
|
|
|
|
|
2020-03-03 13:52:06 +00:00
|
|
|
::
|
2005-05-25 21:43:56 +00:00
|
|
|
|
2020-03-03 13:52:06 +00:00
|
|
|
<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat trans_table
|
|
|
|
From : To
|
|
|
|
: 3600000 3400000 3200000 3000000 2800000
|
|
|
|
3600000: 0 5 0 0 0
|
|
|
|
3400000: 4 0 2 0 0
|
|
|
|
3200000: 0 1 0 2 0
|
|
|
|
3000000: 0 0 1 0 3
|
|
|
|
2800000: 0 0 0 2 0
|
2005-05-25 21:43:56 +00:00
|
|
|
|
|
|
|
3. Configuring cpufreq-stats
|
2020-03-03 13:52:06 +00:00
|
|
|
============================
|
|
|
|
|
|
|
|
To configure cpufreq-stats in your kernel::
|
2005-05-25 21:43:56 +00:00
|
|
|
|
2020-03-03 13:52:06 +00:00
|
|
|
Config Main Menu
|
|
|
|
Power management options (ACPI, APM) --->
|
|
|
|
CPU Frequency scaling --->
|
|
|
|
[*] CPU Frequency scaling
|
|
|
|
[*] CPU frequency translation statistics
|
2005-05-25 21:43:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
"CPU Frequency scaling" (CONFIG_CPU_FREQ) should be enabled to configure
|
|
|
|
cpufreq-stats.
|
|
|
|
|
|
|
|
"CPU frequency translation statistics" (CONFIG_CPU_FREQ_STAT) provides the
|
2017-01-06 05:38:05 +00:00
|
|
|
statistics which includes time_in_state, total_trans and trans_table.
|
2005-05-25 21:43:56 +00:00
|
|
|
|
2017-01-06 05:38:05 +00:00
|
|
|
Once this option is enabled and your CPU supports cpufrequency, you
|
2005-05-25 21:43:56 +00:00
|
|
|
will be able to see the CPU frequency statistics in /sysfs.
|