요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
.. _htm:
===================================
HTM (Hardware Trace Macro)
===================================
Athira Rajeev, 2 Mar 2025
.. contents::
:depth: 3
Basic overview
==============
H_HTM is used as an interface for executing Hardware Trace Macro (HTM)
functions, including setup, configuration, control and dumping of the HTM data.
For using HTM, it is required to setup HTM buffers and HTM operations can
be controlled using the H_HTM hcall. The hcall can be invoked for any core/chip
of the system from within a partition itself. To use this feature, a debugfs
folder called "htmdump" is present under /sys/kernel/debug/powerpc.
HTM debugfs example usage
=========================
.. code-block:: sh
# ls /sys/kernel/debug/powerpc/htmdump/
coreindexonchip htmcaps htmconfigure htmflags htminfo htmsetup
htmstart htmstatus htmtype nodalchipindex nodeindex trace
Details on each file:
* nodeindex, nodalchipindex, coreindexonchip specifies which partition to configure the HTM for.
* htmtype: specifies the type of HTM. Supported target is hardwareTarget.
* trace: is to read the HTM data.
* htmconfigure: Configure/Deconfigure the HTM. Writing 1 to the file will configure the trace, writing 0 to the file will do deconfigure.
* htmstart: start/Stop the HTM. Writing 1 to the file will start the tracing, writing 0 to the file will stop the tracing.
* htmstatus: get the status of HTM. This is needed to understand the HTM state after each operation.
* htmsetup: set the HTM buffer size. Size of HTM buffer is in power of 2
* htminfo: provides the system processor configuration details. This is needed to understand the appropriate values for nodeindex, nodalchipindex, coreindexonchip.
* htmcaps : provides the HTM capabilities like minimum/maximum buffer size, what kind of tracing the HTM supports etc.
* htmflags : allows to pass flags to hcall. Currently supports controlling the wrapping of HTM buffer.
To see the system processor configuration details:
.. code-block:: sh
# cat /sys/kernel/debug/powerpc/htmdump/htminfo > htminfo_file
The result can be interpreted using hexdump.
To collect HTM traces for a partition represented by nodeindex as
zero, nodalchipindex as 1 and coreindexonchip as 12
.. code-block:: sh
# cd /sys/kernel/debug/powerpc/htmdump/
# echo 2 > htmtype
# echo 33 > htmsetup ( sets 8GB memory for HTM buffer, number is size in power of 2 )
This requires a CEC reboot to get the HTM buffers allocated.
.. code-block:: sh
# cd /sys/kernel/debug/powerpc/htmdump/
# echo 2 > htmtype
# echo 0 > nodeindex
# echo 1 > nodalchipindex
# echo 12 > coreindexonchip
# echo 1 > htmflags # to set noWrap for HTM buffers
# echo 1 > htmconfigure # Configure the HTM
# echo 1 > htmstart # Start the HTM
# echo 0 > htmstart # Stop the HTM
# echo 0 > htmconfigure # Deconfigure the HTM
# cat htmstatus # Dump the status of HTM entries as data
Above will set the htmtype and core details, followed by executing respective HTM operation.
Read the HTM trace data
========================
After starting the trace collection, run the workload
of interest. Stop the trace collection after required period
of time, and read the trace file.
.. code-block:: sh
# cat /sys/kernel/debug/powerpc/htmdump/trace > trace_file
This trace file will contain the relevant instruction traces
collected during the workload execution. And can be used as
input file for trace decoders to understand data.
Benefits of using HTM debugfs interface
=======================================
It is now possible to collect traces for a particular core/chip
from within any partition of the system and decode it. Through
this enablement, a small partition can be dedicated to collect the
trace data and analyze to provide important information for Performance
analysis, Software tuning, or Hardware debug.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Hardware Trace Macro 문서
1-13SPDX-License-Identifier는 GPL-2.0입니다. 저자는 Athira Rajeev이며 문서 날짜는 2025년 3월 2일입니다. 목차 깊이는 3입니다.
`H_HTM` interface
14-23`H_HTM`은 Hardware Trace Macro (`HTM`)의 setup, configuration, control, data dump function을 실행하는 interface입니다. HTM buffer를 먼저 설정하고 `H_HTM` hcall로 operation을 제어합니다.
Partition 내부에서 system의 어떤 core/chip에도 hcall을 invoke할 수 있습니다. Debugfs interface는 `/sys/kernel/debug/powerpc/htmdump`에 있습니다.
`htmdump` debugfs file
24-46# ls /sys/kernel/debug/powerpc/htmdump/
coreindexonchip htmcaps htmconfigure htmflags htminfo htmsetup
htmstart htmstatus htmtype nodalchipindex nodeindex trace
| File | 기능 |
|---|---|
| `nodeindex`, `nodalchipindex`, `coreindexonchip` | HTM을 configure할 target partition/core 위치 지정 |
| `htmtype` | HTM type 지정. 지원 target은 `hardwareTarget` |
| `trace` | HTM trace data read |
| `htmconfigure` | `1` write로 configure, `0` write로 deconfigure |
| `htmstart` | `1` write로 trace start, `0` write로 stop |
| `htmstatus` | 각 operation 뒤 HTM state 확인 |
| `htmsetup` | HTM buffer size 설정. Size 값은 2의 exponent |
| `htminfo` | 적절한 index를 고를 system processor configuration 정보 |
| `htmcaps` | 최소/최대 buffer size와 지원 trace 종류 등 capability |
| `htmflags` | Hcall flag 전달. 현재 HTM buffer wrapping 제어 지원 |
Processor 정보와 buffer setup
47-64System processor configuration은 다음 command로 저장합니다.
# cat /sys/kernel/debug/powerpc/htmdump/htminfo > htminfo_file
결과는 `hexdump`로 해석할 수 있습니다.
`nodeindex=0`, `nodalchipindex=1`, `coreindexonchip=12`인 partition trace를 준비하는 첫 단계는 HTM type과 buffer size를 설정하는 것입니다.
# cd /sys/kernel/debug/powerpc/htmdump/
# echo 2 > htmtype
# echo 33 > htmsetup ( sets 8GB memory for HTM buffer, number is size in power of 2 )
`htmsetup` 값 33은 2의 33제곱 byte, 즉 8GB HTM buffer를 뜻합니다. Buffer allocation을 적용하려면 CEC reboot가 필요합니다.
HTM configure/start/stop sequence
65-81# cd /sys/kernel/debug/powerpc/htmdump/
# echo 2 > htmtype
# echo 0 > nodeindex
# echo 1 > nodalchipindex
# echo 12 > coreindexonchip
# echo 1 > htmflags # to set noWrap for HTM buffers
# echo 1 > htmconfigure # Configure the HTM
# echo 1 > htmstart # Start the HTM
# echo 0 > htmstart # Stop the HTM
# echo 0 > htmconfigure # Deconfigure the HTM
# cat htmstatus # Dump the status of HTM entries as data
이 sequence는 `htmtype`과 core location을 설정하고 no-wrap flag를 적용한 뒤 configure, start, stop, deconfigure를 차례로 실행하고 마지막 상태를 dump합니다.
Target 선택과 buffer setup 뒤 trace lifecycle을 순서대로 실행합니다.
HTM trace data 읽기
82-96Trace collection을 시작한 뒤 관심 workload를 실행하고 필요한 시간이 지나면 collection을 stop한 다음 trace file을 읽습니다.
# cat /sys/kernel/debug/powerpc/htmdump/trace > trace_file
Output은 workload 실행 중 수집한 관련 instruction trace를 담으며 trace decoder의 input으로 사용해 data를 해석할 수 있습니다.
Debugfs HTM의 이점
97-104System의 어떤 partition에서도 특정 core/chip trace를 수집하고 decode할 수 있습니다. 작은 partition을 trace 수집/분석 전용으로 두어 performance analysis, software tuning, hardware debug에 필요한 정보를 제공할 수 있습니다.
요약과 해설
htm.rst:1-104`htmdump` debugfs는 buffer allocation과 target core 선택부터 configure/start/stop, trace export까지 HTM lifecycle을 제공합니다. Buffer size 변경에는 CEC reboot가 필요합니다.