Skip to content

Commit 3d18697

Browse files
committed
perf script: Fix output type for dynamically allocated core PMU's
JIRA: https://issues.redhat.com/browse/RHEL-78197 upstream ======== commit 74fb903 Author: Thomas Falcon <thomas.falcon@intel.com> Date: Wed Mar 5 10:39:35 2025 -0600 description =========== This patch was originally posted here: https://lore.kernel.org/all/20241213215421.661139-1-thomas.falcon@intel.com/ I have rebased on top of Arnaldo's patch here: https://lore.kernel.org/all/Z2XCi3PgstSrV0SE@x1/ The original commit message: " perf script output may show different fields on different core PMU's that exist on heterogeneous platforms. For example, perf record -e "{cpu_core/mem-loads-aux/,cpu_core/event=0xcd,\ umask=0x01,ldlat=3,name=MEM_UOPS_RETIRED.LOAD_LATENCY/}:upp"\ -c10000 -W -d -a -- sleep 1 perf script: chromium-browse 46572 [002] 544966.882384: 10000 cpu_core/MEM_UOPS_RETIRED.LOAD_LATENCY/: 7ffdf1391b0c 10268100142 \ |OP LOAD|LVL L1 hit|SNP None|TLB L1 or L2 hit|LCK No|BLK N/A 5 7 0 7fad7c47425d [unknown] (/usr/lib64/libglib-2.0.so.0.8000.3) perf record -e cpu_atom/event=0xd0,umask=0x05,ldlat=3,\ name=MEM_UOPS_RETIRED.LOAD_LATENCY/upp -c10000 -W -d -a -- sleep 1 perf script: gnome-control-c 534224 [023] 544951.816227: 10000 cpu_atom/MEM_UOPS_RETIRED.LOAD_LATENCY/: 7f0aaaa0aae0 [unknown] (/usr/lib64/libglib-2.0.so.0.8000.3) Some fields, such as data_src, are not included by default. The cause is that while one PMU may be assigned a type such as PERF_TYPE_RAW, other core PMU's are dynamically allocated at boot time. If this value does not match an existing PERF_TYPE_X value, output_type(perf_event_attr.type) will return OUTPUT_TYPE_OTHER. Instead search for a core PMU with a matching perf_event_attr type and, if one is found, return PERF_TYPE_RAW to match output of other core PMU's. " Suggested-by: Kan Liang <kan.liang@intel.com> Suggested-by: Ian Rogers <irogers@google.com> Signed-off-by: Thomas Falcon <thomas.falcon@intel.com> Reviewed-by: Ian Rogers <irogers@google.com> Link: https://lore.kernel.org/r/20250305163935.1605312-1-thomas.falcon@intel.com Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Michael Petlan <mpetlan@redhat.com>
1 parent fc8f0d7 commit 3d18697

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

tools/perf/builtin-script.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,20 @@ static inline int output_type(unsigned int type)
400400

401401
static inline int evsel__output_type(struct evsel *evsel)
402402
{
403-
if (evsel->script_output_type == OUTPUT_TYPE_UNSET)
404-
evsel->script_output_type = output_type(evsel->core.attr.type);
403+
int type = evsel->script_output_type;
405404

406-
return evsel->script_output_type;
405+
if (type == OUTPUT_TYPE_UNSET) {
406+
type = output_type(evsel->core.attr.type);
407+
if (type == OUTPUT_TYPE_OTHER) {
408+
struct perf_pmu *pmu = evsel__find_pmu(evsel);
409+
410+
if (pmu && pmu->is_core)
411+
type = PERF_TYPE_RAW;
412+
}
413+
evsel->script_output_type = type;
414+
}
415+
416+
return type;
407417
}
408418

409419
static bool output_set_by_user(void)

0 commit comments

Comments
 (0)