Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

coresight: events: PERF_RECORD_AUX_OUTPUT_HW_ID used for Trace ID

Use the perf_report_aux_output_id() call to output the CoreSight trace ID
and associated CPU as a PERF_RECORD_AUX_OUTPUT_HW_ID record in the
perf.data file.

Signed-off-by: Mike Leach <mike.leach@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20230116124928.5440-14-mike.leach@linaro.org

authored by

Mike Leach and committed by
Suzuki K Poulose
aa19bb4c 7d30d480

+21
+7
drivers/hwtracing/coresight/coresight-etm-perf.c
··· 4 4 * Author: Mathieu Poirier <mathieu.poirier@linaro.org> 5 5 */ 6 6 7 + #include <linux/bitfield.h> 7 8 #include <linux/coresight.h> 8 9 #include <linux/coresight-pmu.h> 9 10 #include <linux/cpumask.h> ··· 449 448 struct perf_output_handle *handle = &ctxt->handle; 450 449 struct coresight_device *sink, *csdev = per_cpu(csdev_src, cpu); 451 450 struct list_head *path; 451 + u64 hw_id; 452 452 453 453 if (!csdev) 454 454 goto fail; ··· 494 492 /* Finally enable the tracer */ 495 493 if (source_ops(csdev)->enable(csdev, event, CS_MODE_PERF)) 496 494 goto fail_disable_path; 495 + 496 + /* output cpu / trace ID in perf record */ 497 + hw_id = FIELD_PREP(CS_AUX_HW_ID_VERSION_MASK, CS_AUX_HW_ID_CURR_VERSION); 498 + hw_id |= FIELD_PREP(CS_AUX_HW_ID_TRACE_ID_MASK, coresight_trace_id_read_cpu_id(cpu)); 499 + perf_report_aux_output_id(event, hw_id); 497 500 498 501 out: 499 502 /* Tell the perf core the event is alive */
+14
include/linux/coresight-pmu.h
··· 7 7 #ifndef _LINUX_CORESIGHT_PMU_H 8 8 #define _LINUX_CORESIGHT_PMU_H 9 9 10 + #include <linux/bits.h> 11 + 10 12 #define CORESIGHT_ETM_PMU_NAME "cs_etm" 11 13 12 14 /* ··· 44 42 #define ETM4_CFG_BIT_TS 11 45 43 #define ETM4_CFG_BIT_RETSTK 12 46 44 #define ETM4_CFG_BIT_VMID_OPT 15 45 + 46 + /* 47 + * Interpretation of the PERF_RECORD_AUX_OUTPUT_HW_ID payload. 48 + * Used to associate a CPU with the CoreSight Trace ID. 49 + * [07:00] - Trace ID - uses 8 bits to make value easy to read in file. 50 + * [59:08] - Unused (SBZ) 51 + * [63:60] - Version 52 + */ 53 + #define CS_AUX_HW_ID_TRACE_ID_MASK GENMASK_ULL(7, 0) 54 + #define CS_AUX_HW_ID_VERSION_MASK GENMASK_ULL(63, 60) 55 + 56 + #define CS_AUX_HW_ID_CURR_VERSION 0 47 57 48 58 #endif