cpufreq-stats.txt 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. (or the time the stats were reset) to the time when a read of a particular
  24. statistic is done. Obviously, stats driver will not have any information
  25. about the frequency transitions before 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. --w------- 1 root root 4096 May 14 16:06 reset
  32. -r--r--r-- 1 root root 4096 May 14 16:06 time_in_state
  33. -r--r--r-- 1 root root 4096 May 14 16:06 total_trans
  34. -r--r--r-- 1 root root 4096 May 14 16:06 trans_table
  35. --------------------------------------------------------------------------------
  36. - reset
  37. Write-only attribute that can be used to reset the stat counters. This can be
  38. useful for evaluating system behaviour under different governors without the
  39. need for a reboot.
  40. - time_in_state
  41. This gives the amount of time spent in each of the frequencies supported by
  42. this CPU. The cat output will have "<frequency> <time>" pair in each line, which
  43. will mean this CPU spent <time> usertime units of time at <frequency>. Output
  44. will have one line for each of the supported frequencies. usertime units here
  45. is 10mS (similar to other time exported in /proc).
  46. --------------------------------------------------------------------------------
  47. <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat time_in_state
  48. 3600000 2089
  49. 3400000 136
  50. 3200000 34
  51. 3000000 67
  52. 2800000 172488
  53. --------------------------------------------------------------------------------
  54. - total_trans
  55. This gives the total number of frequency transitions on this CPU. The cat
  56. output will have a single count which is the total number of frequency
  57. transitions.
  58. --------------------------------------------------------------------------------
  59. <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat total_trans
  60. 20
  61. --------------------------------------------------------------------------------
  62. - trans_table
  63. This will give a fine grained information about all the CPU frequency
  64. transitions. The cat output here is a two dimensional matrix, where an entry
  65. <i,j> (row i, column j) represents the count of number of transitions from
  66. Freq_i to Freq_j. Freq_i is in descending order with increasing rows and
  67. Freq_j is in descending order with increasing columns. The output here also
  68. contains the actual freq values for each row and column for better readability.
  69. If the transition table is bigger than PAGE_SIZE, reading this will
  70. return an -EFBIG error.
  71. --------------------------------------------------------------------------------
  72. <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat trans_table
  73. From : To
  74. : 3600000 3400000 3200000 3000000 2800000
  75. 3600000: 0 5 0 0 0
  76. 3400000: 4 0 2 0 0
  77. 3200000: 0 1 0 2 0
  78. 3000000: 0 0 1 0 3
  79. 2800000: 0 0 0 2 0
  80. --------------------------------------------------------------------------------
  81. 3. Configuring cpufreq-stats
  82. To configure cpufreq-stats in your kernel
  83. Config Main Menu
  84. Power management options (ACPI, APM) --->
  85. CPU Frequency scaling --->
  86. [*] CPU Frequency scaling
  87. [*] CPU frequency translation statistics
  88. "CPU Frequency scaling" (CONFIG_CPU_FREQ) should be enabled to configure
  89. cpufreq-stats.
  90. "CPU frequency translation statistics" (CONFIG_CPU_FREQ_STAT) provides the
  91. statistics which includes time_in_state, total_trans and trans_table.
  92. Once this option is enabled and your CPU supports cpufrequency, you
  93. will be able to see the CPU frequency statistics in /sysfs.