Skip to content

Commit 4a159e6

Browse files
Xu Yangacmel
authored andcommitted
perf jevents: fix breakage when do perf stat on system metric
When do perf stat on sys metric, perf tool output nothing now: $ perf stat -a -M imx95_ddr_read.all -I 1000 $ This command runs on an arm64 machine and the Soc has one DDR hw pmu except one armv8_cortex_a55 pmu. Their maps show as follows: const struct pmu_events_map pmu_events_map[] = { { .arch = "arm64", .cpuid = "0x00000000410fd050", .event_table = { .pmus = pmu_events__arm_cortex_a55, .num_pmus = ARRAY_SIZE(pmu_events__arm_cortex_a55) }, .metric_table = { .pmus = NULL, .num_pmus = 0 } }, static const struct pmu_sys_events pmu_sys_event_tables[] = { { .event_table = { .pmus = pmu_events__freescale_imx95_sys, .num_pmus = ARRAY_SIZE(pmu_events__freescale_imx95_sys) }, .metric_table = { .pmus = pmu_metrics__freescale_imx95_sys, .num_pmus = ARRAY_SIZE(pmu_metrics__freescale_imx95_sys) }, .name = "pmu_events__freescale_imx95_sys", }, Currently, pmu_metrics_table__find() will return NULL when only do perf stat on sys metric. Then parse_groups() will never be called to parse sys metric_name, finally perf tool will exit directly. This should be a common problem. To fix the issue, this will keep the logic before commit f20c15d ("perf pmu-events: Remember the perf_events_map for a PMU") to return a empty metric table rather than a NULL pointer. This should be fine since the removed part just check if the table match provided metric_name. Without these code, the code in parse_groups() will also check the validity of metrci_name too. Fixes: f20c15d ("perf pmu-events: Remember the perf_events_map for a PMU") Reviewed-by: James Clark <[email protected]> Signed-off-by: Xu Yang <[email protected]> Tested-by: Xu Yang <[email protected]> Acked-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Albert Ou <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Alexandre Ghiti <[email protected]> Cc: Athira Rajeev <[email protected]> Cc: Benjamin Gray <[email protected]> Cc: Ben Zong-You Xie <[email protected]> Cc: Bibo Mao <[email protected]> Cc: Clément Le Goffic <[email protected]> Cc: Dima Kogan <[email protected]> Cc: Dr. David Alan Gilbert <[email protected]> Cc: Huacai Chen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Garry <[email protected]> Cc: Kan Liang <[email protected]> Cc: Leo Yan <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Mike Leach <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Bangoria <[email protected]> Cc: Sandipan Das <[email protected]> Cc: Will Deacon <[email protected]> Cc: Yicong Yang <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ian Rogers <[email protected]> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent db26a8c commit 4a159e6

File tree

2 files changed

+2
-22
lines changed

2 files changed

+2
-22
lines changed

tools/perf/pmu-events/empty-pmu-events.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -585,17 +585,7 @@ const struct pmu_metrics_table *perf_pmu__find_metrics_table(struct perf_pmu *pm
585585
if (!map)
586586
return NULL;
587587

588-
if (!pmu)
589-
return &map->metric_table;
590-
591-
for (size_t i = 0; i < map->metric_table.num_pmus; i++) {
592-
const struct pmu_table_entry *table_pmu = &map->metric_table.pmus[i];
593-
const char *pmu_name = &big_c_string[table_pmu->pmu_name.offset];
594-
595-
if (pmu__name_match(pmu, pmu_name))
596-
return &map->metric_table;
597-
}
598-
return NULL;
588+
return &map->metric_table;
599589
}
600590

601591
const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid)

tools/perf/pmu-events/jevents.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,17 +1101,7 @@ def print_system_mapping_table() -> None:
11011101
if (!map)
11021102
return NULL;
11031103
1104-
if (!pmu)
1105-
return &map->metric_table;
1106-
1107-
for (size_t i = 0; i < map->metric_table.num_pmus; i++) {
1108-
const struct pmu_table_entry *table_pmu = &map->metric_table.pmus[i];
1109-
const char *pmu_name = &big_c_string[table_pmu->pmu_name.offset];
1110-
1111-
if (pmu__name_match(pmu, pmu_name))
1112-
return &map->metric_table;
1113-
}
1114-
return NULL;
1104+
return &map->metric_table;
11151105
}
11161106
11171107
const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid)

0 commit comments

Comments
 (0)