[RFC PATCH 0/1] perf: Handle multiple formatted AUX records

Suzuki K Poulose suzuki.poulose at arm.com
Fri Jan 22 10:18:28 EST 2021


This is an RFC patch to explore the solution to a problem we have
in the CoreSight ETM/ETE PMU.

CoreSight ETM trace allows instruction level tracing of Arm CPUs.
The ETM generates the CPU excecution trace and pumps it into CoreSight
AMBA Trace Bus and is collected by a different CoreSight component
(traditionally CoreSight TMC-ETR /ETB/ETF), called "sink".
Important to note that there is no guarantee that every CPU has
a dedicated sink.  Thus multiple ETMs could pump the trace data
into the same "sink" and thus they apply additional formatting
of the trace data for the user to decode it properly and attribute
the trace data to the corresponding ETM.

However, with the introduction of Arm Trace buffer Extensions (TRBE),
we now have a dedicated per-CPU architected sink for collecting the
trace. Since the TRBE is always per-CPU, it doesn't apply any formatting
of the trace. The support for this driver is under review [1].

Now a system could have a per-cpu TRBE and one or more shared
TMC-ETRs on the system. A user could choose a "specific" sink
for a perf session (e.g, a TMC-ETR) or the driver could automatically
select the nearest sink for a given ETM. It is possible that
some ETMs could end up using TMC-ETR (e.g, if the TRBE is not
usable on the CPU) while the others using TRBE in a single
perf session. Thus we now have "formatted" trace collected
from TMC-ETR and "unformatted" trace collected from TRBE.
However, we don't get into a situation where a single event
could end up using TMC-ETR & TRBE. i.e, any AUX buffer is
guaranteed to be either RAW or FORMATTED, but not a mix
of both.

As for perf decoding, we need to know the type of the data
in the individual AUX buffers, so that it can set up the
"OpenCSD" (library for decoding CoreSight trace) decoder
instance appropriately. Thus the perf.data file must conatin
the hints for the tool to decode the data correctly.

Since this is a runtime variable, and perf tool doesn't have
a control on what sink gets used (in case of automatic sink
selection), we need this information made available from
the PMU driver for each AUX record.

This patch is an attempt to solve the problem by, adding an
AUX flag for each AUX record to indicate the type of the
trace in them. It can be defined as a PMU specific flag,
which each PMU could interpret in its on way (e.g,
PERF_AUX_FLAG_PMU_FLAG_1 or could be a dedicated
flag for the CoreSight in a "generic" form
PERF_AUX_FLAG_ALT_FMT (Thanks Mike Leach for the name).

We are looking for suggestions on how best to solve this
problem and happy to explore other options if there is
a preferred way of solving this.

[1] https://lkml.kernel.org/r/1610511498-4058-1-git-send-email-anshuman.khandual@arm.com

Suzuki K Poulose (1):
  perf: Handle multiple formatted AUX records

 drivers/hwtracing/coresight/coresight-etm-perf.c | 2 ++
 include/linux/coresight.h                        | 1 +
 include/uapi/linux/perf_event.h                  | 1 +
 3 files changed, 4 insertions(+)

-- 
2.24.1




More information about the linux-arm-kernel mailing list