···11+22+ CPU frequency and voltage scaling statictics in the Linux(TM) kernel33+44+55+ L i n u x c p u f r e q - s t a t s d r i v e r66+77+ - information for users -88+99+1010+ Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>1111+1212+Contents1313+1. Introduction1414+2. Statistics Provided (with example)1515+3. Configuring cpufreq-stats1616+1717+1818+1. Introduction1919+2020+cpufreq-stats is a driver that provices CPU frequency statistics for each CPU.2121+This statistics is provided in /sysfs as a bunch of read_only interfaces. This2222+interface (when configured) will appear in a seperate directory under cpufreq2323+in /sysfs (<sysfs root>/devices/system/cpu/cpuX/cpufreq/stats/) for each CPU.2424+Various statistics will form read_only files under this directory.2525+2626+This driver is designed to be independent of any particular cpufreq_driver2727+that may be running on your CPU. So, it will work with any cpufreq_driver.2828+2929+3030+2. Statistics Provided (with example)3131+3232+cpufreq stats provides following statistics (explained in detail below).3333+- time_in_state3434+- total_trans3535+- trans_table3636+3737+All the statistics will be from the time the stats driver has been inserted 3838+to the time when a read of a particular statistic is done. Obviously, stats 3939+driver will not have any information about the the frequcny transitions before4040+the stats driver insertion.4141+4242+--------------------------------------------------------------------------------4343+<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # ls -l4444+total 04545+drwxr-xr-x 2 root root 0 May 14 16:06 .4646+drwxr-xr-x 3 root root 0 May 14 15:58 ..4747+-r--r--r-- 1 root root 4096 May 14 16:06 time_in_state4848+-r--r--r-- 1 root root 4096 May 14 16:06 total_trans4949+-r--r--r-- 1 root root 4096 May 14 16:06 trans_table5050+--------------------------------------------------------------------------------5151+5252+- time_in_state5353+This gives the amount of time spent in each of the frequencies supported by5454+this CPU. The cat output will have "<frequency> <time>" pair in each line, which5555+will mean this CPU spent <time> usertime units of time at <frequency>. Output5656+will have one line for each of the supported freuencies. usertime units here 5757+is 10mS (similar to other time exported in /proc).5858+5959+--------------------------------------------------------------------------------6060+<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat time_in_state 6161+3600000 20896262+3400000 1366363+3200000 346464+3000000 676565+2800000 1724886666+--------------------------------------------------------------------------------6767+6868+6969+- total_trans7070+This gives the total number of frequency transitions on this CPU. The cat 7171+output will have a single count which is the total number of frequency7272+transitions.7373+7474+--------------------------------------------------------------------------------7575+<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat total_trans7676+207777+--------------------------------------------------------------------------------7878+7979+- trans_table8080+This will give a fine grained information about all the CPU frequency8181+transitions. The cat output here is a two dimensional matrix, where an entry8282+<i,j> (row i, column j) represents the count of number of transitions from 8383+Freq_i to Freq_j. Freq_i is in descending order with increasing rows and 8484+Freq_j is in descending order with increasing columns. The output here also 8585+contains the actual freq values for each row and column for better readability.8686+8787+--------------------------------------------------------------------------------8888+<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat trans_table8989+ From : To9090+ : 3600000 3400000 3200000 3000000 2800000 9191+ 3600000: 0 5 0 0 0 9292+ 3400000: 4 0 2 0 0 9393+ 3200000: 0 1 0 2 0 9494+ 3000000: 0 0 1 0 3 9595+ 2800000: 0 0 0 2 0 9696+--------------------------------------------------------------------------------9797+9898+9999+3. Configuring cpufreq-stats100100+101101+To configure cpufreq-stats in your kernel102102+Config Main Menu103103+ Power management options (ACPI, APM) --->104104+ CPU Frequency scaling --->105105+ [*] CPU Frequency scaling106106+ <*> CPU frequency translation statistics 107107+ [*] CPU frequency translation statistics details108108+109109+110110+"CPU Frequency scaling" (CONFIG_CPU_FREQ) should be enabled to configure111111+cpufreq-stats.112112+113113+"CPU frequency translation statistics" (CONFIG_CPU_FREQ_STAT) provides the114114+basic statistics which includes time_in_state and total_trans.115115+116116+"CPU frequency translation statistics details" (CONFIG_CPU_FREQ_STAT_DETAILS)117117+provides fine grained cpufreq stats by trans_table. The reason for having a118118+seperate config option for trans_table is:119119+- trans_table goes against the traditional /sysfs rule of one value per120120+ interface. It provides a whole bunch of value in a 2 dimensional matrix121121+ form.122122+123123+Once these two options are enabled and your CPU supports cpufrequency, you124124+will be able to see the CPU frequency statistics in /sysfs.125125+126126+127127+128128+