Skip to content

powerpc/htm: Add interface to expose HTM trace data via perf

Athira Rajeev linux-perf-users linuxppc-dev sashiko-reviews 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5powerpc/htm: Add interface to expose HTM trace data via perfarch/powerpc/perf/Makefile arch/powerpc/perf/htm-perf.c+308 -11 reply
2/5powerpc/htm: Add support to setup and free aux buffer for capturing HTM dataarch/powerpc/perf/htm-perf.c+160 -21 reply
3/5powerpc/perf: Capture the HTM memory configuration as part of perf dataarch/powerpc/perf/htm-perf.c+108 -21 reply
4/5docs: ABI: sysfs-bus-event_source-devices-htm: Document sysfs event format entries for htm pmuDocumentation/ABI/testing/sysfs-bus-event_source-devices-htm+21 -00 replies
5/5powerpc/perf/htm: Add documentation for Hardware Trace Macro PMUDocumentation/arch/powerpc/htm.rst+134 -30 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/5] powerpc/htm: Add interface to expose HTM trace data via perf

H_HTM (Hardware Trace Macro) hypervisor call is an HCALL to export data from Hardware Trace Macro (HTM) function. Patchset adds support for setup, configuration and control of HTM functions as well as trace data collection via perf PMU interface.

H_HTM is used as an interface for executing Hardware Trace Macro (HTM) functions, including setup, configuration, control and dumping of the HTM trace data. 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.

HTM perf interface usage:
The HTM (Hardware Trace Macro) perf interface enables collection and analysis of hardware trace data from PowerPC systems. This interface allows users to capture detailed execution traces for performance analysis and debugging. The interface uses AUX infrastructure for capturing of trace data.

Patchset includes powerpc kernel side changes.

Patch 1 introduces the HTM PMU interface with event configuration support for specifying target hardware (node, chip, core) and trace type. It integrates H_HTM hcall wrappers for starting, stopping, and controlling HTM trace collection.

Patch 2 implements AUX buffer infrastructure by adding setup_aux and free_aux callbacks, enabling perf to allocate and manage auxiliary buffers for HTM data.

Patch 3 extends trace collection to capture system memory configuration alongside trace data, using PERF_SAMPLE_RAW records to mark data boundaries in the AUX buffer for post-processing.

Patches 4 and 5 provide comprehensive documentation for the HTM PMU interface, including ABI documentation for sysfs attributes and user-facing documentation with usage examples and workflows.

perf tools side patches will be posted separately in the linux-perf-users mailing list.

Event Configuration:

Use "perf record" with the htm PMU event. The event is configured using named parameters that specify the target hardware location and trace type:

- htm_type
- Type of HTM trace to collect (bits 0-3)
- nodeindex
- Node index in the system topology (bits 4-11)
- nodalchipindex
- Chip index within the specified node (bits 12-19)
- coreindexonchip
- Core index on the specified chip (bits 20-27)

event: "config:0-27"
htm_type: "config:0-3"
nodeindex: "config:4-11"
nodalchipindex: "config:12-19"
coreindexonchip: "config:20-27"

1) nodeindex, nodalchipindex, coreindexonchip: this specifies which partition to configure the HTM for.
2) htmtype: specifies the type of HTM.

Event Syntax:
The event configuration uses named parameters::

htm/nodeindex=N,nodalchipindex=C,coreindexonchip=R,htm_type=T/

Where:

- N = node index
- C = chip index within the node
- R = core index on the chip
- T = HTM type

Basic Usage Example:
To collect HTM trace data for a specific chip:

 # perf record -C 1 -e htm/nodalchipindex=2,nodeindex=0,htm_type=1/ <workload>

In this example:

- nodeindex=0: Target node 0
- nodalchipindex=2: Target chip 2 within node 0
- htm_type=1: HTM trace type 1

Output Files:
After running "perf record", the following files are generated:

   # ls htm.bin.*
   htm.bin.n0.p2.c0 htm.bin.n1.p3.c0  # Binary trace files
   # ls translation.*
   translation.n0.p2.c0  translation.n1.p3.c0  # Memory configuration files

These files contain:

- **htm.bin.*** - Raw HTM trace data in binary format
- **translation.*** - Memory address translation information for decoding

Trace Data Processing:
Process the collected trace data using perf script:

   # perf script -D

This command:

1. Reads the perf.data file
2. Decodes HTM trace data using translation files
3. Displays human-readable trace output

The decoder automatically:

- Translates physical addresses to logical addresses
- Creates decoded output files for analysis
- Correlates trace data with memory mappings

Here's a complete example of collecting and analyzing HTM traces:

# Step 1: Collect trace data
perf record -C 1 -e htm/nodalchipindex=2,nodeindex=0,htm_type=1/ sleep 5

# Step 2: Verify output files

   ls htm.bin.*        # Binary trace files
   ls translation.*    # Memory configuration files
   ls perf.data        # Perf data file

# Step 3: Decode and view traces
perf script -D > decoded_trace.txt

# Step 4: Analyze with perf report to see the hot logical address perf report

Thanks
Athira

Athira Rajeev (5):
powerpc/htm: Add interface to expose HTM trace data via perf powerpc/htm: Add support to setup and free aux buffer for capturing
HTM data
powerpc/perf: Capture the HTM memory configuration as part of perf
data
docs: ABI: sysfs-bus-event_source-devices-htm: Document sysfs event
format entries for htm pmu
powerpc/perf/htm: Add documentation for Hardware Trace Macro PMU

 .../sysfs-bus-event_source-devices-htm        |  21 +
 Documentation/arch/powerpc/htm.rst            | 137 ++++-
 arch/powerpc/perf/Makefile                    |   2 +-
 arch/powerpc/perf/htm-perf.c                  | 571 ++++++++++++++++++
 4 files changed, 727 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-event_source-devices-htm
 create mode 100644 arch/powerpc/perf/htm-perf.c
Signature · 1 line
2.52.0