요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
==========================================
General Description of sysfs CPUFreq Stats
==========================================
information for users
Author: Venkatesh Pallipadi <[email protected]>
.. Contents
1. Introduction
2. Statistics Provided (with example)
3. Configuring cpufreq-stats
1. Introduction
===============
cpufreq-stats is a driver that provides CPU frequency statistics for each CPU.
These statistics are provided in /sysfs as a bunch of read_only interfaces. This
interface (when configured) will appear in a separate directory under cpufreq
in /sysfs (<sysfs root>/devices/system/cpu/cpuX/cpufreq/stats/) for each CPU.
Various statistics will form read_only files under this directory.
This driver is designed to be independent of any particular cpufreq_driver
that may be running on your CPU. So, it will work with any cpufreq_driver.
2. Statistics Provided (with example)
=====================================
cpufreq stats provides following statistics (explained in detail below).
- time_in_state
- total_trans
- trans_table
All the statistics will be from the time the stats driver has been inserted
(or the time the stats were reset) to the time when a read of a particular
statistic is done. Obviously, stats driver will not have any information
about the frequency transitions before the stats driver insertion.
::
<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # ls -l
total 0
drwxr-xr-x 2 root root 0 May 14 16:06 .
drwxr-xr-x 3 root root 0 May 14 15:58 ..
--w------- 1 root root 4096 May 14 16:06 reset
-r--r--r-- 1 root root 4096 May 14 16:06 time_in_state
-r--r--r-- 1 root root 4096 May 14 16:06 total_trans
-r--r--r-- 1 root root 4096 May 14 16:06 trans_table
- **reset**
Write-only attribute that can be used to reset the stat counters. This can be
useful for evaluating system behaviour under different governors without the
need for a reboot.
- **time_in_state**
This gives the amount of time spent in each of the frequencies supported by
this CPU. The cat output will have "<frequency> <time>" pair in each line, which
will mean this CPU spent <time> usertime units of time at <frequency>. Output
will have one line for each of the supported frequencies. usertime units here
is 10mS (similar to other time exported in /proc).
::
<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat time_in_state
3600000 2089
3400000 136
3200000 34
3000000 67
2800000 172488
- **total_trans**
This gives the total number of frequency transitions on this CPU. The cat
output will have a single count which is the total number of frequency
transitions.
::
<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat total_trans
20
- **trans_table**
This will give a fine grained information about all the CPU frequency
transitions. The cat output here is a two dimensional matrix, where an entry
<i,j> (row i, column j) represents the count of number of transitions from
Freq_i to Freq_j. Freq_i rows and Freq_j columns follow the sorting order in
which the driver has provided the frequency table initially to the cpufreq core
and so can be sorted (ascending or descending) or unsorted. The output here
also contains the actual freq values for each row and column for better
readability.
If the transition table is bigger than PAGE_SIZE, reading this will
return an -EFBIG error.
::
<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat trans_table
From : To
: 3600000 3400000 3200000 3000000 2800000
3600000: 0 5 0 0 0
3400000: 4 0 2 0 0
3200000: 0 1 0 2 0
3000000: 0 0 1 0 3
2800000: 0 0 0 2 0
3. Configuring cpufreq-stats
============================
To configure cpufreq-stats in your kernel::
Config Main Menu
Power management options (ACPI, APM) --->
CPU Frequency scaling --->
[*] CPU Frequency scaling
[*] CPU frequency translation statistics
"CPU Frequency scaling" (CONFIG_CPU_FREQ) should be enabled to configure
cpufreq-stats.
"CPU frequency translation statistics" (CONFIG_CPU_FREQ_STAT) provides the
statistics which includes time_in_state, total_trans and trans_table.
Once this option is enabled and your CPU supports cpufrequency, you
will be able to see the CPU frequency statistics in /sysfs.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Sysfs CPUFreq 통계 일반 설명
1-18.. SPDX-License-Identifier: GPL-2.0
Sysfs CPUFreq 통계 일반 설명
사용자를 위한 정보
저자: Venkatesh Pallipadi <[email protected]>
목차:
- 1. 소개
- 2. 제공되는 통계와 예제
- 3. cpufreq-stats 설정
1. 소개
19-311. 소개
cpufreq-stats는 CPU마다 CPU frequency 통계를 제공하는 driver입니다. 통계는 `/sysfs`에 여러 read-only interface로 제공됩니다. 설정하면 CPU별 cpufreq directory 아래의 `<sysfs root>/devices/system/cpu/cpuX/cpufreq/stats/`에 별도 directory가 나타나며, 여러 통계가 이 directory 아래의 read-only file로 생성됩니다.
이 driver는 CPU에서 실행 중일 수 있는 특정 `cpufreq_driver`와 독립적으로 설계되었으므로 어떤 `cpufreq_driver`와도 동작합니다.
2. 제공되는 통계
32-562. 제공되는 통계와 예제
cpufreq stats는 다음 통계를 제공합니다.
- time_in_state
- total_trans
- trans_table
모든 통계의 측정 구간은 stats driver가 삽입된 시점 또는 통계가 reset된 시점부터 특정 통계를 읽는 시점까지입니다. Stats driver가 삽입되기 전에 일어난 frequency transition에 관한 정보는 제공할 수 없습니다.
<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # ls -l
total 0
drwxr-xr-x 2 root root 0 May 14 16:06 .
drwxr-xr-x 3 root root 0 May 14 15:58 ..
--w------- 1 root root 4096 May 14 16:06 reset
-r--r--r-- 1 root root 4096 May 14 16:06 time_in_state
-r--r--r-- 1 root root 4096 May 14 16:06 total_trans
-r--r--r-- 1 root root 4096 May 14 16:06 trans_table
reset
57-62`reset`
통계 counter를 reset할 때 사용하는 write-only attribute입니다. Reboot하지 않고 서로 다른 governor에서 system 동작을 평가할 때 유용합니다.
time_in_state
63-80`time_in_state`
이 CPU가 지원하는 각 frequency에서 소비한 시간을 제공합니다. `cat` 출력의 각 줄은 `<frequency> <time>` pair이며, CPU가 `<frequency>`에서 `<time>` usertime unit 동안 실행되었다는 뜻입니다. 지원하는 frequency마다 한 줄이 출력됩니다. 여기서 usertime unit은 `/proc`에 export되는 다른 시간과 비슷하게 10ms입니다.
<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat time_in_state
3600000 2089
3400000 136
3200000 34
3000000 67
2800000 172488
total_trans
81-91`total_trans`
이 CPU에서 발생한 frequency transition의 총 횟수를 제공합니다. `cat` 출력은 전체 transition 횟수 하나입니다.
<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat total_trans
20
trans_table
92-116`trans_table`
모든 CPU frequency transition에 관한 세부 정보를 제공합니다. `cat` 출력은 2차원 matrix이며, entry `<i,j>`, 즉 row i와 column j는 `Freq_i`에서 `Freq_j`로 전환한 횟수를 나타냅니다. `Freq_i` row와 `Freq_j` column은 driver가 처음 cpufreq core에 frequency table을 제공한 정렬 순서를 따르므로 ascending, descending 또는 unsorted일 수 있습니다. 가독성을 위해 각 row와 column의 실제 frequency 값도 출력합니다.
Transition table이 `PAGE_SIZE`보다 크면 이 attribute를 읽을 때 `-EFBIG` error가 반환됩니다.
<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat trans_table
From : To
: 3600000 3400000 3200000 3000000 2800000
3600000: 0 5 0 0 0
3400000: 4 0 2 0 0
3200000: 0 1 0 2 0
3000000: 0 0 1 0 3
2800000: 0 0 0 2 0
`trans_table` 예제의 From row와 To column을 구조화된 matrix로 다시 표현했습니다. Cell 값은 transition 횟수입니다.
3. cpufreq-stats 설정
117-1363. cpufreq-stats 설정
Kernel에서 cpufreq-stats를 설정하는 menu 경로는 다음과 같습니다.
Config Main Menu
Power management options (ACPI, APM) --->
CPU Frequency scaling --->
[*] CPU Frequency scaling
[*] CPU frequency translation statistics
cpufreq-stats를 설정하려면 `CPU Frequency scaling`, 즉 `CONFIG_CPU_FREQ`를 활성화해야 합니다.
`CPU frequency translation statistics`, 즉 `CONFIG_CPU_FREQ_STAT`은 `time_in_state`, `total_trans`, `trans_table`을 포함한 통계를 제공합니다.
이 option을 활성화하고 CPU가 CPU frequency scaling을 지원하면 `/sysfs`에서 CPU frequency 통계를 볼 수 있습니다.
요약과 해설
cpufreq-stats.rst:1-136cpufreq-stats는 CPU별로 `/sys/devices/system/cpu/cpuX/cpufreq/stats/` 아래에 frequency residency와 transition 통계를 export하며 특정 cpufreq driver에 종속되지 않습니다.
`time_in_state`는 frequency별 체류 시간을 10ms usertime unit으로, `total_trans`는 전체 전환 횟수를, `trans_table`은 출발 frequency와 도착 frequency 사이의 전환 횟수 matrix를 제공합니다.
`reset`을 쓰면 reboot 없이 counter를 초기화할 수 있습니다. 기능을 사용하려면 `CONFIG_CPU_FREQ`와 `CONFIG_CPU_FREQ_STAT`을 활성화해야 합니다.