blob: a873855c811d63f3a47cd2ec830404abb89d48c8 [file] [log] [blame]
Venkatesh Pallipadi21e30242005-05-25 14:43:56 -07001
Matt LaPlante53cb4722006-10-03 22:55:17 +02002 CPU frequency and voltage scaling statistics in the Linux(TM) kernel
Venkatesh Pallipadi21e30242005-05-25 14:43:56 -07003
4
5 L i n u x c p u f r e q - s t a t s d r i v e r
6
7 - information for users -
8
9
10 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
11
12Contents
131. Introduction
142. Statistics Provided (with example)
153. Configuring cpufreq-stats
16
17
181. Introduction
19
Matt LaPlantea982ac02007-05-09 07:35:06 +020020cpufreq-stats is a driver that provides CPU frequency statistics for each CPU.
Matt LaPlante53cb4722006-10-03 22:55:17 +020021These statistics are provided in /sysfs as a bunch of read_only interfaces. This
22interface (when configured) will appear in a separate directory under cpufreq
Venkatesh Pallipadi21e30242005-05-25 14:43:56 -070023in /sysfs (<sysfs root>/devices/system/cpu/cpuX/cpufreq/stats/) for each CPU.
24Various statistics will form read_only files under this directory.
25
26This driver is designed to be independent of any particular cpufreq_driver
27that may be running on your CPU. So, it will work with any cpufreq_driver.
28
29
302. Statistics Provided (with example)
31
32cpufreq stats provides following statistics (explained in detail below).
33- time_in_state
34- total_trans
35- trans_table
36
Viresh Kumar7de962c2017-01-06 11:08:05 +053037All the statistics will be from the time the stats driver has been inserted
38(or the time the stats were reset) to the time when a read of a particular
39statistic is done. Obviously, stats driver will not have any information
40about the frequency transitions before the stats driver insertion.
Venkatesh Pallipadi21e30242005-05-25 14:43:56 -070041
42--------------------------------------------------------------------------------
43<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # ls -l
44total 0
45drwxr-xr-x 2 root root 0 May 14 16:06 .
46drwxr-xr-x 3 root root 0 May 14 15:58 ..
Markus Mayeree7930e2016-11-07 10:02:23 -080047--w------- 1 root root 4096 May 14 16:06 reset
Venkatesh Pallipadi21e30242005-05-25 14:43:56 -070048-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
Markus Mayeree7930e2016-11-07 10:02:23 -080053- reset
54Write-only attribute that can be used to reset the stat counters. This can be
55useful for evaluating system behaviour under different governors without the
56need for a reboot.
57
Venkatesh Pallipadi21e30242005-05-25 14:43:56 -070058- time_in_state
59This gives the amount of time spent in each of the frequencies supported by
60this CPU. The cat output will have "<frequency> <time>" pair in each line, which
61will mean this CPU spent <time> usertime units of time at <frequency>. Output
Matt LaPlantea2ffd272006-10-03 22:49:15 +020062will have one line for each of the supported frequencies. usertime units here
Venkatesh Pallipadi21e30242005-05-25 14:43:56 -070063is 10mS (similar to other time exported in /proc).
64
65--------------------------------------------------------------------------------
66<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat time_in_state
673600000 2089
683400000 136
693200000 34
703000000 67
712800000 172488
72--------------------------------------------------------------------------------
73
74
75- total_trans
76This gives the total number of frequency transitions on this CPU. The cat
77output will have a single count which is the total number of frequency
78transitions.
79
80--------------------------------------------------------------------------------
81<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat total_trans
8220
83--------------------------------------------------------------------------------
84
85- trans_table
86This will give a fine grained information about all the CPU frequency
87transitions. 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
89Freq_i to Freq_j. Freq_i is in descending order with increasing rows and
90Freq_j is in descending order with increasing columns. The output here also
91contains the actual freq values for each row and column for better readability.
92
Gautham R. Shenoyf7bc9b22017-11-07 13:39:29 +053093If the transition table is bigger than PAGE_SIZE, reading this will
94return an -EFBIG error.
95
Venkatesh Pallipadi21e30242005-05-25 14:43:56 -070096--------------------------------------------------------------------------------
97<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat trans_table
98 From : To
99 : 3600000 3400000 3200000 3000000 2800000
100 3600000: 0 5 0 0 0
101 3400000: 4 0 2 0 0
102 3200000: 0 1 0 2 0
103 3000000: 0 0 1 0 3
104 2800000: 0 0 0 2 0
105--------------------------------------------------------------------------------
106
107
1083. Configuring cpufreq-stats
109
110To configure cpufreq-stats in your kernel
111Config Main Menu
112 Power management options (ACPI, APM) --->
113 CPU Frequency scaling --->
114 [*] CPU Frequency scaling
Jean Delvare3732b302016-09-08 23:05:07 +0200115 [*] CPU frequency translation statistics
Venkatesh Pallipadi21e30242005-05-25 14:43:56 -0700116
117
118"CPU Frequency scaling" (CONFIG_CPU_FREQ) should be enabled to configure
119cpufreq-stats.
120
121"CPU frequency translation statistics" (CONFIG_CPU_FREQ_STAT) provides the
Viresh Kumar7de962c2017-01-06 11:08:05 +0530122statistics which includes time_in_state, total_trans and trans_table.
Venkatesh Pallipadi21e30242005-05-25 14:43:56 -0700123
Viresh Kumar7de962c2017-01-06 11:08:05 +0530124Once this option is enabled and your CPU supports cpufrequency, you
Venkatesh Pallipadi21e30242005-05-25 14:43:56 -0700125will be able to see the CPU frequency statistics in /sysfs.