Skip to content

Commit c788ef6

Browse files
captain5050acmel
authored andcommitted
perf metrics: Ensure at least 1 id per metric
We may have no events for a metric evaluated to a constant. In such a case ensure a tool event is at least evaluated for metric parsing and displaying. Fixes: 8586d27 ("perf metrics: Don't add all tool events for sharing") Signed-off-by: Ian Rogers <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Garry <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Xing Zhengjun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 37402d5 commit c788ef6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tools/perf/util/metricgroup.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,7 @@ static int parse_ids(bool metric_no_merge, struct perf_pmu *fake_pmu,
13721372

13731373
*out_evlist = NULL;
13741374
if (!metric_no_merge || hashmap__size(ids->ids) == 0) {
1375+
bool added_event = false;
13751376
int i;
13761377
/*
13771378
* We may fail to share events between metrics because a tool
@@ -1393,8 +1394,16 @@ static int parse_ids(bool metric_no_merge, struct perf_pmu *fake_pmu,
13931394
if (!tmp)
13941395
return -ENOMEM;
13951396
ids__insert(ids->ids, tmp);
1397+
added_event = true;
13961398
}
13971399
}
1400+
if (!added_event && hashmap__size(ids->ids) == 0) {
1401+
char *tmp = strdup("duration_time");
1402+
1403+
if (!tmp)
1404+
return -ENOMEM;
1405+
ids__insert(ids->ids, tmp);
1406+
}
13981407
}
13991408
ret = metricgroup__build_event_string(&events, ids, modifier,
14001409
has_constraint);

0 commit comments

Comments
 (0)