blob: 53d62c1e1c94f68531756d20c80e50c48aa718b3 [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
20cpufreq-stats is a driver that provices 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
37All the statistics will be from the time the stats driver has been inserted
38to the time when a read of a particular statistic is done. Obviously, stats
Tobias Klauserd533f672005-09-10 00:26:46 -070039driver will not have any information about the frequency transitions before
Venkatesh Pallipadi21e30242005-05-25 14:43:56 -070040the stats driver insertion.
41
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 ..
47-r--r--r-- 1 root root 4096 May 14 16:06 time_in_state
48-r--r--r-- 1 root root 4096 May 14 16:06 total_trans
49-r--r--r-- 1 root root 4096 May 14 16:06 trans_table
50--------------------------------------------------------------------------------
51
52- time_in_state
53This gives the amount of time spent in each of the frequencies supported by
54this CPU. The cat output will have "<frequency> <time>" pair in each line, which
55will mean this CPU spent <time> usertime units of time at <frequency>. Output
Matt LaPlantea2ffd272006-10-03 22:49:15 +020056will have one line for each of the supported frequencies. usertime units here
Venkatesh Pallipadi21e30242005-05-25 14:43:56 -070057is 10mS (similar to other time exported in /proc).
58
59--------------------------------------------------------------------------------
60<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat time_in_state
613600000 2089
623400000 136
633200000 34
643000000 67
652800000 172488
66--------------------------------------------------------------------------------
67
68
69- total_trans
70This gives the total number of frequency transitions on this CPU. The cat
71output will have a single count which is the total number of frequency
72transitions.
73
74--------------------------------------------------------------------------------
75<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat total_trans
7620
77--------------------------------------------------------------------------------
78
79- trans_table
80This will give a fine grained information about all the CPU frequency
81transitions. The cat output here is a two dimensional matrix, where an entry
82<i,j> (row i, column j) represents the count of number of transitions from
83Freq_i to Freq_j. Freq_i is in descending order with increasing rows and
84Freq_j is in descending order with increasing columns. The output here also
85contains the actual freq values for each row and column for better readability.
86
87--------------------------------------------------------------------------------
88<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat trans_table
89 From : To
90 : 3600000 3400000 3200000 3000000 2800000
91 3600000: 0 5 0 0 0
92 3400000: 4 0 2 0 0
93 3200000: 0 1 0 2 0
94 3000000: 0 0 1 0 3
95 2800000: 0 0 0 2 0
96--------------------------------------------------------------------------------
97
98
993. Configuring cpufreq-stats
100
101To configure cpufreq-stats in your kernel
102Config Main Menu
103 Power management options (ACPI, APM) --->
104 CPU Frequency scaling --->
105 [*] CPU Frequency scaling
106 <*> CPU frequency translation statistics
107 [*] CPU frequency translation statistics details
108
109
110"CPU Frequency scaling" (CONFIG_CPU_FREQ) should be enabled to configure
111cpufreq-stats.
112
113"CPU frequency translation statistics" (CONFIG_CPU_FREQ_STAT) provides the
114basic statistics which includes time_in_state and total_trans.
115
116"CPU frequency translation statistics details" (CONFIG_CPU_FREQ_STAT_DETAILS)
117provides fine grained cpufreq stats by trans_table. The reason for having a
Matt LaPlante53cb4722006-10-03 22:55:17 +0200118separate config option for trans_table is:
Venkatesh Pallipadi21e30242005-05-25 14:43:56 -0700119- trans_table goes against the traditional /sysfs rule of one value per
120 interface. It provides a whole bunch of value in a 2 dimensional matrix
121 form.
122
123Once these two options are enabled and your CPU supports cpufrequency, you
124will be able to see the CPU frequency statistics in /sysfs.
125
126
127
128