xref: /linux/Documentation/arch/powerpc/htm.rst (revision 746680ec6696585e30db3e18c93a63df9cbec39c)
1.. SPDX-License-Identifier: GPL-2.0
2.. _htm:
3
4===================================
5HTM (Hardware Trace Macro)
6===================================
7
8Athira Rajeev, 2 Mar 2025
9
10.. contents::
11    :depth: 3
12
13
14Basic overview
15==============
16
17H_HTM is used as an interface for executing Hardware Trace Macro (HTM)
18functions, including setup, configuration, control and dumping of the HTM data.
19For using HTM, it is required to setup HTM buffers and HTM operations can
20be controlled using the H_HTM hcall. The hcall can be invoked for any core/chip
21of the system from within a partition itself. To use this feature, a debugfs
22folder called "htmdump" is present under /sys/kernel/debug/powerpc.
23
24
25HTM debugfs example usage
26=========================
27
28.. code-block:: sh
29
30  #  ls /sys/kernel/debug/powerpc/htmdump/
31  coreindexonchip  htmcaps  htmconfigure  htmflags  htminfo  htmsetup
32  htmstart  htmstatus  htmtype  nodalchipindex  nodeindex  trace
33
34Details on each file:
35
36* nodeindex, nodalchipindex, coreindexonchip specifies which partition to configure the HTM for.
37* htmtype: specifies the type of HTM. Supported target is hardwareTarget.
38* trace: is to read the HTM data.
39* htmconfigure: Configure/Deconfigure the HTM. Writing 1 to the file will configure the trace, writing 0 to the file will do deconfigure.
40* htmstart: start/Stop the HTM. Writing 1 to the file will start the tracing, writing 0 to the file will stop the tracing.
41* htmstatus: get the status of HTM. This is needed to understand the HTM state after each operation.
42* htmsetup: set the HTM buffer size. Size of HTM buffer is in power of 2
43* htminfo: provides the system processor configuration details. This is needed to understand the appropriate values for nodeindex, nodalchipindex, coreindexonchip.
44* htmcaps : provides the HTM capabilities like minimum/maximum buffer size, what kind of tracing the HTM supports etc.
45* htmflags : allows to pass flags to hcall. Currently supports controlling the wrapping of HTM buffer.
46
47To see the system processor configuration details:
48
49.. code-block:: sh
50
51  # cat /sys/kernel/debug/powerpc/htmdump/htminfo > htminfo_file
52
53The result can be interpreted using hexdump.
54
55To collect HTM traces for a partition represented by nodeindex as
56zero, nodalchipindex as 1 and coreindexonchip as 12
57
58.. code-block:: sh
59
60  # cd /sys/kernel/debug/powerpc/htmdump/
61  # echo 2 > htmtype
62  # echo 33 > htmsetup ( sets 8GB memory for HTM buffer, number is size in power of 2 )
63
64This requires a CEC reboot to get the HTM buffers allocated.
65
66.. code-block:: sh
67
68  # cd /sys/kernel/debug/powerpc/htmdump/
69  # echo 2 > htmtype
70  # echo 0 > nodeindex
71  # echo 1 > nodalchipindex
72  # echo 12 > coreindexonchip
73  # echo 1 > htmflags     # to set noWrap for HTM buffers
74  # echo 1 > htmconfigure # Configure the HTM
75  # echo 1 > htmstart     # Start the HTM
76  # echo 0 > htmstart     # Stop the HTM
77  # echo 0 > htmconfigure # Deconfigure the HTM
78  # cat htmstatus         # Dump the status of HTM entries as data
79
80Above will set the htmtype and core details, followed by executing respective HTM operation.
81
82Read the HTM trace data
83========================
84
85After starting the trace collection, run the workload
86of interest. Stop the trace collection after required period
87of time, and read the trace file.
88
89.. code-block:: sh
90
91  # cat /sys/kernel/debug/powerpc/htmdump/trace > trace_file
92
93This trace file will contain the relevant instruction traces
94collected during the workload execution. And can be used as
95input file for trace decoders to understand data.
96
97Benefits of using HTM debugfs interface
98=======================================
99
100It is now possible to collect traces for a particular core/chip
101from within any partition of the system and decode it. Through
102this enablement, a small partition can be dedicated to collect the
103trace data and analyze to provide important information for Performance
104analysis, Software tuning, or Hardware debug.
105