1+ .. SPDX-License-Identifier: GPL-2.0
12
2- CPU frequency and voltage scaling statistics in the Linux(TM) kernel
3+ ==========================================
4+ General Description of sysfs CPUFreq Stats
5+ ==========================================
36
7+ information for users
48
5- L i n u x c p u f r e q - s t a t s d r i v e r
69
7- - information for users -
10+ Author: Venkatesh Pallipadi <[email protected] > 811
12+ .. Contents
913
10- Venkatesh Pallipadi <
[email protected] >
11-
12- Contents
13- 1. Introduction
14- 2. Statistics Provided (with example)
15- 3. Configuring cpufreq-stats
14+ 1. Introduction
15+ 2. Statistics Provided (with example)
16+ 3. Configuring cpufreq-stats
1617
1718
1819 1. Introduction
20+ ===============
1921
2022cpufreq-stats is a driver that provides CPU frequency statistics for each CPU.
2123These statistics are provided in /sysfs as a bunch of read_only interfaces. This
@@ -28,8 +30,10 @@ that may be running on your CPU. So, it will work with any cpufreq_driver.
2830
2931
30322. Statistics Provided (with example)
33+ =====================================
3134
3235cpufreq stats provides following statistics (explained in detail below).
36+
3337- time_in_state
3438- total_trans
3539- trans_table
@@ -39,53 +43,57 @@ All the statistics will be from the time the stats driver has been inserted
3943statistic is done. Obviously, stats driver will not have any information
4044about the frequency transitions before the stats driver insertion.
4145
42- --------------------------------------------------------------------------------
43- <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # ls -l
44- total 0
45- drwxr-xr-x 2 root root 0 May 14 16:06 .
46- drwxr-xr-x 3 root root 0 May 14 15:58 ..
47- --w------- 1 root root 4096 May 14 16:06 reset
48- -r--r--r-- 1 root root 4096 May 14 16:06 time_in_state
49- -r--r--r-- 1 root root 4096 May 14 16:06 total_trans
50- -r--r--r-- 1 root root 4096 May 14 16:06 trans_table
51- --------------------------------------------------------------------------------
52-
53- - reset
46+ ::
47+
48+ <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # ls -l
49+ total 0
50+ drwxr-xr-x 2 root root 0 May 14 16:06 .
51+ drwxr-xr-x 3 root root 0 May 14 15:58 ..
52+ --w------- 1 root root 4096 May 14 16:06 reset
53+ -r--r--r-- 1 root root 4096 May 14 16:06 time_in_state
54+ -r--r--r-- 1 root root 4096 May 14 16:06 total_trans
55+ -r--r--r-- 1 root root 4096 May 14 16:06 trans_table
56+
57+ - **reset **
58+
5459Write-only attribute that can be used to reset the stat counters. This can be
5560useful for evaluating system behaviour under different governors without the
5661need for a reboot.
5762
58- - time_in_state
63+ - **time_in_state **
64+
5965This gives the amount of time spent in each of the frequencies supported by
6066this CPU. The cat output will have "<frequency> <time>" pair in each line, which
6167will mean this CPU spent <time> usertime units of time at <frequency>. Output
62- will have one line for each of the supported frequencies. usertime units here
68+ will have one line for each of the supported frequencies. usertime units here
6369is 10mS (similar to other time exported in /proc).
6470
65- --------------------------------------------------------------------------------
66- <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat time_in_state
67- 3600000 2089
68- 3400000 136
69- 3200000 34
70- 3000000 67
71- 2800000 172488
72- --------------------------------------------------------------------------------
71+ ::
7372
73+ <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat time_in_state
74+ 3600000 2089
75+ 3400000 136
76+ 3200000 34
77+ 3000000 67
78+ 2800000 172488
7479
75- - total_trans
76- This gives the total number of frequency transitions on this CPU. The cat
80+
81+ - **total_trans **
82+
83+ This gives the total number of frequency transitions on this CPU. The cat
7784output will have a single count which is the total number of frequency
7885transitions.
7986
80- --------------------------------------------------------------------------------
81- <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat total_trans
82- 20
83- --------------------------------------------------------------------------------
87+ ::
88+
89+ <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat total_trans
90+ 20
91+
92+ - **trans_table **
8493
85- - trans_table
8694This will give a fine grained information about all the CPU frequency
8795transitions. The cat output here is a two dimensional matrix, where an entry
88- <i,j> (row i, column j) represents the count of number of transitions from
96+ <i,j> (row i, column j) represents the count of number of transitions from
8997Freq_i to Freq_j. Freq_i rows and Freq_j columns follow the sorting order in
9098which the driver has provided the frequency table initially to the cpufreq core
9199and so can be sorted (ascending or descending) or unsorted. The output here
@@ -95,26 +103,27 @@ readability.
95103If the transition table is bigger than PAGE_SIZE, reading this will
96104return an -EFBIG error.
97105
98- --------------------------------------------------------------------------------
99- <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat trans_table
100- From : To
101- : 3600000 3400000 3200000 3000000 2800000
102- 3600000: 0 5 0 0 0
103- 3400000: 4 0 2 0 0
104- 3200000: 0 1 0 2 0
105- 3000000: 0 0 1 0 3
106- 2800000: 0 0 0 2 0
107- --------------------------------------------------------------------------------
106+ ::
108107
108+ <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat trans_table
109+ From : To
110+ : 3600000 3400000 3200000 3000000 2800000
111+ 3600000: 0 5 0 0 0
112+ 3400000: 4 0 2 0 0
113+ 3200000: 0 1 0 2 0
114+ 3000000: 0 0 1 0 3
115+ 2800000: 0 0 0 2 0
109116
1101173. Configuring cpufreq-stats
118+ ============================
119+
120+ To configure cpufreq-stats in your kernel::
111121
112- To configure cpufreq-stats in your kernel
113- Config Main Menu
114- Power management options (ACPI, APM) --->
115- CPU Frequency scaling --->
116- [*] CPU Frequency scaling
117- [*] CPU frequency translation statistics
122+ Config Main Menu
123+ Power management options (ACPI, APM) --->
124+ CPU Frequency scaling --->
125+ [*] CPU Frequency scaling
126+ [*] CPU frequency translation statistics
118127
119128
120129"CPU Frequency scaling" (CONFIG_CPU_FREQ) should be enabled to configure
0 commit comments