요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
======================================
HNS3 Performance Monitoring Unit (PMU)
======================================
HNS3(HiSilicon network system 3) Performance Monitoring Unit (PMU) is an
End Point device to collect performance statistics of HiSilicon SoC NIC.
On Hip09, each SICL(Super I/O cluster) has one PMU device.
HNS3 PMU supports collection of performance statistics such as bandwidth,
latency, packet rate and interrupt rate.
Each HNS3 PMU supports 8 hardware events.
HNS3 PMU driver
===============
The HNS3 PMU driver registers a perf PMU with the name of its sicl id.::
/sys/bus/event_source/devices/hns3_pmu_sicl_<sicl_id>
PMU driver provides description of available events, filter modes, format,
identifier and cpumask in sysfs.
The "events" directory describes the event code of all supported events
shown in perf list.
The "filtermode" directory describes the supported filter modes of each
event.
The "format" directory describes all formats of the config (events) and
config1 (filter options) fields of the perf_event_attr structure.
The "identifier" file shows version of PMU hardware device.
The "bdf_min" and "bdf_max" files show the supported bdf range of each
pmu device.
The "hw_clk_freq" file shows the hardware clock frequency of each pmu
device.
Example usage of checking event code and subevent code::
$# cat /sys/bus/event_source/devices/hns3_pmu_sicl_0/events/dly_tx_normal_to_mac_time
config=0x00204
$# cat /sys/bus/event_source/devices/hns3_pmu_sicl_0/events/dly_tx_normal_to_mac_packet_num
config=0x10204
Each performance statistic has a pair of events to get two values to
calculate real performance data in userspace.
The bits 0~15 of config (here 0x0204) are the true hardware event code. If
two events have same value of bits 0~15 of config, that means they are
event pair. And the bit 16 of config indicates getting counter 0 or
counter 1 of hardware event.
After getting two values of event pair in userspace, the formula of
computation to calculate real performance data is:::
counter 0 / counter 1
Example usage of checking supported filter mode::
$# cat /sys/bus/event_source/devices/hns3_pmu_sicl_0/filtermode/bw_ssu_rpu_byte_num
filter mode supported: global/port/port-tc/func/func-queue/
Example usage of perf::
$# perf list
hns3_pmu_sicl_0/bw_ssu_rpu_byte_num/ [kernel PMU event]
hns3_pmu_sicl_0/bw_ssu_rpu_time/ [kernel PMU event]
------------------------------------------
$# perf stat -g -e hns3_pmu_sicl_0/bw_ssu_rpu_byte_num,global=1/ -e hns3_pmu_sicl_0/bw_ssu_rpu_time,global=1/ -I 1000
or
$# perf stat -g -e hns3_pmu_sicl_0/config=0x00002,global=1/ -e hns3_pmu_sicl_0/config=0x10002,global=1/ -I 1000
Filter modes
--------------
1. global mode
PMU collect performance statistics for all HNS3 PCIe functions of IO DIE.
Set the "global" filter option to 1 will enable this mode.
Example usage of perf::
$# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,global=1/ -I 1000
2. port mode
PMU collect performance statistic of one whole physical port. The port id
is same as mac id. The "tc" filter option must be set to 0xF in this mode,
here tc stands for traffic class.
Example usage of perf::
$# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,port=0,tc=0xF/ -I 1000
3. port-tc mode
PMU collect performance statistic of one tc of physical port. The port id
is same as mac id. The "tc" filter option must be set to 0 ~ 7 in this
mode.
Example usage of perf::
$# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,port=0,tc=0/ -I 1000
4. func mode
PMU collect performance statistic of one PF/VF. The function id is BDF of
PF/VF, its conversion formula::
func = (bus << 8) + (device << 3) + (function)
for example:
BDF func
35:00.0 0x3500
35:00.1 0x3501
35:01.0 0x3508
In this mode, the "queue" filter option must be set to 0xFFFF.
Example usage of perf::
$# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,bdf=0x3500,queue=0xFFFF/ -I 1000
5. func-queue mode
PMU collect performance statistic of one queue of PF/VF. The function id
is BDF of PF/VF, the "queue" filter option must be set to the exact queue
id of function.
Example usage of perf::
$# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,bdf=0x3500,queue=0/ -I 1000
6. func-intr mode
PMU collect performance statistic of one interrupt of PF/VF. The function
id is BDF of PF/VF, the "intr" filter option must be set to the exact
interrupt id of function.
Example usage of perf::
$# perf stat -a -e hns3_pmu_sicl_0/config=0x00301,bdf=0x3500,intr=0/ -I 1000
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Hip09 HNS3 PMU
1-12`HNS3 (HiSilicon network system 3) Performance Monitoring Unit (PMU)`은 HiSilicon SoC NIC의 performance statistics를 수집하는 End Point device입니다.
Hip09에서는 각 SICL (Super I/O cluster)에 PMU device가 하나 있으며, bandwidth, latency, packet rate, interrupt rate를 수집합니다. 각 HNS3 PMU는 8 hardware events를 지원합니다.
Perf PMU와 sysfs interface
13-40HNS3 PMU driver는 SICL ID를 이름에 넣어 perf PMU를 등록합니다.
/sys/bus/event_source/devices/hns3_pmu_sicl_<sicl_id>
Sysfs에는 사용 가능한 event, filter mode, format, identifier, cpumask가 설명됩니다.
| Sysfs 항목 | 의미 |
|---|---|
| `events` | `perf list`에 표시할 event code |
| `filtermode` | Event마다 지원하는 filter mode |
| `format` | `config` event와 `config1` filter option 형식 |
| `identifier` | PMU hardware device 버전 |
| `bdf_min`, `bdf_max` | PMU가 지원하는 BDF 범위 |
| `hw_clk_freq` | PMU hardware clock frequency |
| `cpumask` | PMU driver가 sysfs로 제공하는 CPU mask |
`format` directory는 `perf_event_attr` 구조체의 `config` event field와 `config1` filter option field 형식을 정의합니다. `bdf_min`과 `bdf_max`는 각 PMU device가 지원하는 BDF 범위를, `hw_clk_freq`는 hardware clock frequency를 나타냅니다.
Event pair 계산과 perf 사용
41-77Event code와 subevent code를 읽는 예제입니다.
$# cat /sys/bus/event_source/devices/hns3_pmu_sicl_0/events/dly_tx_normal_to_mac_time
config=0x00204
$# cat /sys/bus/event_source/devices/hns3_pmu_sicl_0/events/dly_tx_normal_to_mac_packet_num
config=0x10204
각 performance statistic은 userspace에서 실제 값을 계산할 두 값을 얻도록 event pair를 사용합니다.
| Bit 또는 식 | 역할 |
|---|---|
| `config[15:0]` (`bits 0~15`) | 실제 hardware event code; 같으면 event pair |
| `config[16]` (`bit 16`) | Hardware event의 counter 0 또는 counter 1 선택 |
| Userspace 계산 | `counter 0 / counter 1` |
counter 0 / counter 1
Event가 지원하는 filter mode는 `filtermode`에서 확인합니다.
$# cat /sys/bus/event_source/devices/hns3_pmu_sicl_0/filtermode/bw_ssu_rpu_byte_num
filter mode supported: global/port/port-tc/func/func-queue/
`perf list`의 symbolic event pair 또는 같은 hardware code의 raw `config` pair를 `perf stat -g`로 함께 측정할 수 있습니다.
$# perf list
hns3_pmu_sicl_0/bw_ssu_rpu_byte_num/ [kernel PMU event]
hns3_pmu_sicl_0/bw_ssu_rpu_time/ [kernel PMU event]
------------------------------------------
$# perf stat -g -e hns3_pmu_sicl_0/bw_ssu_rpu_byte_num,global=1/ -e hns3_pmu_sicl_0/bw_ssu_rpu_time,global=1/ -I 1000
or
$# perf stat -g -e hns3_pmu_sicl_0/config=0x00002,global=1/ -e hns3_pmu_sicl_0/config=0x10002,global=1/ -I 1000
`perf list`에서 확인한 byte/time event alias와 동일한 raw config pair를 대응시켰습니다.
Global과 physical port filter
78-96| Mode | 대상과 필수 option |
|---|---|
| Global | `global=1`; IO DIE의 모든 HNS3 PCIe function |
| Port | `port=<mac id>,tc=0xF`; physical port 전체 |
| Port-TC | `port=<mac id>,tc=0~7`; port의 traffic class 하나 |
| Func | `bdf=<func>,queue=0xFFFF`; PF/VF 하나 |
| Func-Queue | `bdf=<func>,queue=<id>`; PF/VF queue 하나 |
| Func-Intr | `bdf=<func>,intr=<id>`; PF/VF interrupt 하나 |
Global mode는 `global=1`로 IO DIE의 모든 HNS3 PCIe function 통계를 수집합니다.
$# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,global=1/ -I 1000
Port mode는 physical port 하나 전체를 셉니다. Port ID는 MAC ID와 같으며, `tc`는 traffic class를 뜻하므로 이 mode에서는 반드시 `tc=0xF`로 설정합니다.
$# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,port=0,tc=0xF/ -I 1000
Traffic class와 PF/VF filter
97-121Port-TC mode는 physical port의 traffic class 하나를 셉니다. Port ID는 MAC ID와 같고 `tc`는 0부터 7까지의 정확한 class ID여야 합니다.
$# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,port=0,tc=0/ -I 1000
Func mode는 PF/VF 하나의 통계를 수집합니다. Function ID는 PF/VF의 BDF를 다음 식으로 변환한 값입니다.
func = (bus << 8) + (device << 3) + (function)
| BDF | `func` |
|---|---|
| `35:00.0` | `0x3500` |
| `35:00.1` | `0x3501` |
| `35:01.0` | `0x3508` |
Func mode에서는 queue 전체를 뜻하도록 `queue` filter option을 반드시 `0xFFFF`로 설정합니다.
$# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,bdf=0x3500,queue=0xFFFF/ -I 1000
PF/VF queue와 interrupt filter
122-136Func-Queue mode는 PF/VF의 queue 하나를 세므로 `bdf`에 function ID를, `queue`에 정확한 queue ID를 설정합니다.
$# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,bdf=0x3500,queue=0/ -I 1000
Func-Intr mode는 PF/VF의 interrupt 하나를 세므로 `bdf`에 function ID를, `intr`에 정확한 interrupt ID를 설정합니다.
$# perf stat -a -e hns3_pmu_sicl_0/config=0x00301,bdf=0x3500,intr=0/ -I 1000
운영 요약
hns3-pmu.rst:1-136SICL별 HNS3 PMU에서 같은 hardware event code의 counter pair를 함께 측정한 뒤 비율을 계산하고, 원하는 IO DIE, port, traffic class, PF/VF, queue 또는 interrupt로 범위를 좁힙니다.