About Kernel Documentation Linux Kernel Contact Linux Resources Linux Blog

Documentation / cpu-freq / cpufreq-stats.txt




Custom Search

Based on kernel version 4.13.3. Page generated on 2017-09-23 13:54 EST.

1	
2	     CPU frequency and voltage scaling statistics in the Linux(TM) kernel
3	
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	
12	Contents
13	1. Introduction
14	2. Statistics Provided (with example)
15	3. Configuring cpufreq-stats
16	
17	
18	1. Introduction
19	
20	cpufreq-stats is a driver that provides CPU frequency statistics for each CPU.
21	These statistics are provided in /sysfs as a bunch of read_only interfaces. This
22	interface (when configured) will appear in a separate directory under cpufreq
23	in /sysfs (<sysfs root>/devices/system/cpu/cpuX/cpufreq/stats/) for each CPU.
24	Various statistics will form read_only files under this directory.
25	
26	This driver is designed to be independent of any particular cpufreq_driver
27	that may be running on your CPU. So, it will work with any cpufreq_driver.
28	
29	
30	2. Statistics Provided (with example)
31	
32	cpufreq stats provides following statistics (explained in detail below).
33	-  time_in_state
34	-  total_trans
35	-  trans_table
36	
37	All 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
39	statistic is done. Obviously, stats driver will not have any information
40	about the frequency transitions before the stats driver insertion.
41	
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
54	Write-only attribute that can be used to reset the stat counters. This can be
55	useful for evaluating system behaviour under different governors without the
56	need for a reboot.
57	
58	-  time_in_state
59	This gives the amount of time spent in each of the frequencies supported by
60	this CPU. The cat output will have "<frequency> <time>" pair in each line, which
61	will 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 
63	is 10mS (similar to other time exported in /proc).
64	
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	--------------------------------------------------------------------------------
73	
74	
75	-  total_trans
76	This gives the total number of frequency transitions on this CPU. The cat 
77	output will have a single count which is the total number of frequency
78	transitions.
79	
80	--------------------------------------------------------------------------------
81	<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat total_trans
82	20
83	--------------------------------------------------------------------------------
84	
85	-  trans_table
86	This will give a fine grained information about all the CPU frequency
87	transitions. 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 
89	Freq_i to Freq_j. Freq_i is in descending order with increasing rows and 
90	Freq_j is in descending order with increasing columns. The output here also 
91	contains the actual freq values for each row and column for better readability.
92	
93	--------------------------------------------------------------------------------
94	<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat trans_table
95	   From  :    To
96	         :   3600000   3400000   3200000   3000000   2800000 
97	  3600000:         0         5         0         0         0 
98	  3400000:         4         0         2         0         0 
99	  3200000:         0         1         0         2         0 
100	  3000000:         0         0         1         0         3 
101	  2800000:         0         0         0         2         0 
102	--------------------------------------------------------------------------------
103	
104	
105	3. Configuring cpufreq-stats
106	
107	To configure cpufreq-stats in your kernel
108	Config Main Menu
109		Power management options (ACPI, APM)  --->
110			CPU Frequency scaling  --->
111				[*] CPU Frequency scaling
112				[*]   CPU frequency translation statistics
113	
114	
115	"CPU Frequency scaling" (CONFIG_CPU_FREQ) should be enabled to configure
116	cpufreq-stats.
117	
118	"CPU frequency translation statistics" (CONFIG_CPU_FREQ_STAT) provides the
119	statistics which includes time_in_state, total_trans and trans_table.
120	
121	Once this option is enabled and your CPU supports cpufrequency, you
122	will be able to see the CPU frequency statistics in /sysfs.
Hide Line Numbers
About Kernel Documentation Linux Kernel Contact Linux Resources Linux Blog

Information is copyright its respective author. All material is available from the Linux Kernel Source distributed under a GPL License. This page is provided as a free service by mjmwired.net.