cpufreq-stats.rst 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ==========================================
  3. General Description of sysfs CPUFreq Stats
  4. ==========================================
  5. information for users
  6. Author: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
  7. .. Contents
  8. 1. Introduction
  9. 2. Statistics Provided (with example)
  10. 3. Configuring cpufreq-stats
  11. 1. Introduction
  12. ===============
  13. cpufreq-stats is a driver that provides CPU frequency statistics for each CPU.
  14. These statistics are provided in /sysfs as a bunch of read_only interfaces. This
  15. interface (when configured) will appear in a separate directory under cpufreq
  16. in /sysfs (<sysfs root>/devices/system/cpu/cpuX/cpufreq/stats/) for each CPU.
  17. Various statistics will form read_only files under this directory.
  18. This driver is designed to be independent of any particular cpufreq_driver
  19. that may be running on your CPU. So, it will work with any cpufreq_driver.
  20. 2. Statistics Provided (with example)
  21. =====================================
  22. cpufreq stats provides following statistics (explained in detail below).
  23. - time_in_state
  24. - total_trans
  25. - trans_table
  26. All the statistics will be from the time the stats driver has been inserted
  27. (or the time the stats were reset) to the time when a read of a particular
  28. statistic is done. Obviously, stats driver will not have any information
  29. about the frequency transitions before the stats driver insertion.
  30. ::
  31. <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # ls -l
  32. total 0
  33. drwxr-xr-x 2 root root 0 May 14 16:06 .
  34. drwxr-xr-x 3 root root 0 May 14 15:58 ..
  35. --w------- 1 root root 4096 May 14 16:06 reset
  36. -r--r--r-- 1 root root 4096 May 14 16:06 time_in_state
  37. -r--r--r-- 1 root root 4096 May 14 16:06 total_trans
  38. -r--r--r-- 1 root root 4096 May 14 16:06 trans_table
  39. - **reset**
  40. Write-only attribute that can be used to reset the stat counters. This can be
  41. useful for evaluating system behaviour under different governors without the
  42. need for a reboot.
  43. - **time_in_state**
  44. This gives the amount of time spent in each of the frequencies supported by
  45. this CPU. The cat output will have "<frequency> <time>" pair in each line, which
  46. will mean this CPU spent <time> usertime units of time at <frequency>. Output
  47. will have one line for each of the supported frequencies. usertime units here
  48. is 10mS (similar to other time exported in /proc).
  49. ::
  50. <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat time_in_state
  51. 3600000 2089
  52. 3400000 136
  53. 3200000 34
  54. 3000000 67
  55. 2800000 172488
  56. - **total_trans**
  57. This gives the total number of frequency transitions on this CPU. The cat
  58. output will have a single count which is the total number of frequency
  59. transitions.
  60. ::
  61. <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat total_trans
  62. 20
  63. - **trans_table**
  64. This will give a fine grained information about all the CPU frequency
  65. transitions. The cat output here is a two dimensional matrix, where an entry
  66. <i,j> (row i, column j) represents the count of number of transitions from
  67. Freq_i to Freq_j. Freq_i rows and Freq_j columns follow the sorting order in
  68. which the driver has provided the frequency table initially to the cpufreq core
  69. and so can be sorted (ascending or descending) or unsorted. The output here
  70. also contains the actual freq values for each row and column for better
  71. readability.
  72. If the transition table is bigger than PAGE_SIZE, reading this will
  73. return an -EFBIG error.
  74. ::
  75. <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat trans_table
  76. From : To
  77. : 3600000 3400000 3200000 3000000 2800000
  78. 3600000: 0 5 0 0 0
  79. 3400000: 4 0 2 0 0
  80. 3200000: 0 1 0 2 0
  81. 3000000: 0 0 1 0 3
  82. 2800000: 0 0 0 2 0
  83. 3. Configuring cpufreq-stats
  84. ============================
  85. To configure cpufreq-stats in your kernel::
  86. Config Main Menu
  87. Power management options (ACPI, APM) --->
  88. CPU Frequency scaling --->
  89. [*] CPU Frequency scaling
  90. [*] CPU frequency translation statistics
  91. "CPU Frequency scaling" (CONFIG_CPU_FREQ) should be enabled to configure
  92. cpufreq-stats.
  93. "CPU frequency translation statistics" (CONFIG_CPU_FREQ_STAT) provides the
  94. statistics which includes time_in_state, total_trans and trans_table.
  95. Once this option is enabled and your CPU supports cpufrequency, you
  96. will be able to see the CPU frequency statistics in /sysfs.