1 .. SPDX-License-Identifier: GPL-2.0
3 .. include:: ../disclaimer-zh_TW.rst
5 :Original: :doc:`../../../cpu-freq/cpufreq-stats`
6 :Translator: Yanteng Si <siyanteng@loongson.cn>
7 Hu Haowen <src.res@email.cn>
9 .. _tw_cpufreq-stats.rst:
12 ==========================================
13 sysfs CPUFreq Stats的一般說明
14 ==========================================
19 作者: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
31 cpufreq-stats是一個爲每個CPU提供CPU頻率統計的驅動。
32 這些統計數據在/sysfs中以一堆只讀接口的形式提供。這個接口(在配置好後)將出現在
33 /sysfs(<sysfs root>/devices/system/cpu/cpuX/cpufreq/stats/)中cpufreq下的一個單
37 此驅動是獨立於任何可能運行在你所用CPU上的特定cpufreq_driver而設計的。因此,它將與所有
42 =====================================
44 cpufreq stats提供了以下統計數據(在下面詳細解釋)。
50 所有的統計數據將從統計驅動被載入的時間(或統計被重置的時間)開始,到某一統計數據被讀取的時間爲止。
51 顯然,統計驅動不會有任何關於統計驅動載入之前的頻率轉換信息。
55 <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # ls -l
57 drwxr-xr-x 2 root root 0 May 14 16:06 .
58 drwxr-xr-x 3 root root 0 May 14 15:58 ..
59 --w------- 1 root root 4096 May 14 16:06 reset
60 -r--r--r-- 1 root root 4096 May 14 16:06 time_in_state
61 -r--r--r-- 1 root root 4096 May 14 16:06 total_trans
62 -r--r--r-- 1 root root 4096 May 14 16:06 trans_table
66 只寫屬性,可用於重置統計計數器。這對於評估不同調節器下的系統行爲非常有用,且無需重啓。
71 此項給出了這個CPU所支持的每個頻率所花費的時間。cat輸出的每一行都會有"<frequency>
72 <time>"對,表示這個CPU在<frequency>上花費了<time>個usertime單位的時間。這裡的
73 usertime單位是10mS(類似於/proc中輸出的其他時間)。
77 <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat time_in_state
87 給出了這個CPU上頻率轉換的總次數。cat的輸出將有一個單一的計數,這就是頻率轉換的總數。
91 <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat total_trans
96 這將提供所有CPU頻率轉換的細粒度信息。這裡的cat輸出是一個二維矩陣,其中一個條目<i, j>(第
97 i行,第j列)代表從Freq_i到Freq_j的轉換次數。Freq_i行和Freq_j列遵循驅動最初提供給cpufreq
98 核的頻率表的排序順序,因此可以排序(升序或降序)或不排序。 這裡的輸出也包含了每行每列的實際
101 如果轉換表大於PAGE_SIZE,讀取時將返回一個-EFBIG錯誤。
105 <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat trans_table
107 : 3600000 3400000 3200000 3000000 2800000
115 ============================
117 要在你的內核中配置cpufreq-stats::
120 Power management options (ACPI, APM) --->
121 CPU Frequency scaling --->
122 [*] CPU Frequency scaling
123 [*] CPU frequency translation statistics
126 "CPU Frequency scaling" (CONFIG_CPU_FREQ) 應該被啓用以配置cpufreq-stats。
128 "CPU frequency translation statistics" (CONFIG_CPU_FREQ_STAT)提供了包括
129 time_in_state、total_trans和trans_table的統計數據。
131 一旦啓用了這個選項,並且你的CPU支持cpufrequency,你就可以在/sysfs中看到CPU頻率統計。