cpufreq-stats.txt 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. CPU frequency and voltage scaling statistics in the Linux(TM) kernel
  2. L i n u x c p u f r e q - s t a t s d r i v e r
  3. - information for users -
  4. Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
  5. Contents
  6. 1. Introduction
  7. 2. Statistics Provided (with example)
  8. 3. Configuring cpufreq-stats
  9. 1. Introduction
  10. cpufreq-stats is a driver that provides CPU frequency statistics for each CPU.
  11. These statistics are provided in /sysfs as a bunch of read_only interfaces. This
  12. interface (when configured) will appear in a separate directory under cpufreq
  13. in /sysfs (<sysfs root>/devices/system/cpu/cpuX/cpufreq/stats/) for each CPU.
  14. Various statistics will form read_only files under this directory.
  15. This driver is designed to be independent of any particular cpufreq_driver
  16. that may be running on your CPU. So, it will work with any cpufreq_driver.
  17. 2. Statistics Provided (with example)
  18. cpufreq stats provides following statistics (explained in detail below).
  19. - time_in_state
  20. - total_trans
  21. - trans_table
  22. All the statistics will be from the time the stats driver has been inserted
  23. to the time when a read of a particular statistic is done. Obviously, stats
  24. driver will not have any information about the frequency transitions before
  25. the stats driver insertion.
  26. --------------------------------------------------------------------------------
  27. <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # ls -l
  28. total 0
  29. drwxr-xr-x 2 root root 0 May 14 16:06 .
  30. drwxr-xr-x 3 root root 0 May 14 15:58 ..
  31. -r--r--r-- 1 root root 4096 May 14 16:06 time_in_state
  32. -r--r--r-- 1 root root 4096 May 14 16:06 total_trans
  33. -r--r--r-- 1 root root 4096 May 14 16:06 trans_table
  34. --------------------------------------------------------------------------------
  35. - time_in_state
  36. This gives the amount of time spent in each of the frequencies supported by
  37. this CPU. The cat output will have "<frequency> <time>" pair in each line, which
  38. will mean this CPU spent <time> usertime units of time at <frequency>. Output
  39. will have one line for each of the supported frequencies. usertime units here
  40. is 10mS (similar to other time exported in /proc).
  41. --------------------------------------------------------------------------------
  42. <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat time_in_state
  43. 3600000 2089
  44. 3400000 136
  45. 3200000 34
  46. 3000000 67
  47. 2800000 172488
  48. --------------------------------------------------------------------------------
  49. - total_trans
  50. This gives the total number of frequency transitions on this CPU. The cat
  51. output will have a single count which is the total number of frequency
  52. transitions.
  53. --------------------------------------------------------------------------------
  54. <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat total_trans
  55. 20
  56. --------------------------------------------------------------------------------
  57. - trans_table
  58. This will give a fine grained information about all the CPU frequency
  59. transitions. The cat output here is a two dimensional matrix, where an entry
  60. <i,j> (row i, column j) represents the count of number of transitions from
  61. Freq_i to Freq_j. Freq_i is in descending order with increasing rows and
  62. Freq_j is in descending order with increasing columns. The output here also
  63. contains the actual freq values for each row and column for better readability.
  64. --------------------------------------------------------------------------------
  65. <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat trans_table
  66. From : To
  67. : 3600000 3400000 3200000 3000000 2800000
  68. 3600000: 0 5 0 0 0
  69. 3400000: 4 0 2 0 0
  70. 3200000: 0 1 0 2 0
  71. 3000000: 0 0 1 0 3
  72. 2800000: 0 0 0 2 0
  73. --------------------------------------------------------------------------------
  74. 3. Configuring cpufreq-stats
  75. To configure cpufreq-stats in your kernel
  76. Config Main Menu
  77. Power management options (ACPI, APM) --->
  78. CPU Frequency scaling --->
  79. [*] CPU Frequency scaling
  80. <*> CPU frequency translation statistics
  81. [*] CPU frequency translation statistics details
  82. "CPU Frequency scaling" (CONFIG_CPU_FREQ) should be enabled to configure
  83. cpufreq-stats.
  84. "CPU frequency translation statistics" (CONFIG_CPU_FREQ_STAT) provides the
  85. basic statistics which includes time_in_state and total_trans.
  86. "CPU frequency translation statistics details" (CONFIG_CPU_FREQ_STAT_DETAILS)
  87. provides fine grained cpufreq stats by trans_table. The reason for having a
  88. separate config option for trans_table is:
  89. - trans_table goes against the traditional /sysfs rule of one value per
  90. interface. It provides a whole bunch of value in a 2 dimensional matrix
  91. form.
  92. Once these two options are enabled and your CPU supports cpufrequency, you
  93. will be able to see the CPU frequency statistics in /sysfs.