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

perf list: Display metric expressions for --details option

Display metric expression itself when --details is specified.

Current list with no details:

# perf list metrics
...
TopDownL1:
IPC
[Instructions Per Cycle (per logical thread)]
SLOTS
[Total issue-pipeline slots]
...

Detailed output with metric formula:

# perf list --details metrics
...
TopDownL1:
IPC
[Instructions Per Cycle (per logical thread)]
[inst_retired.any / cpu_clk_unhalted.thread]
SLOTS
[Total issue-pipeline slots]
[4*(( cpu_clk_unhalted.thread_any / 2 ) if #smt_on else cycles)]
...

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20190213123246.4015-6-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
33bbc571 714a92d8

+14 -7
+4 -4
tools/perf/builtin-list.c
··· 82 82 else if (strcmp(argv[i], "sdt") == 0) 83 83 print_sdt_events(NULL, NULL, raw_dump); 84 84 else if (strcmp(argv[i], "metric") == 0) 85 - metricgroup__print(true, false, NULL, raw_dump); 85 + metricgroup__print(true, false, NULL, raw_dump, details_flag); 86 86 else if (strcmp(argv[i], "metricgroup") == 0) 87 - metricgroup__print(false, true, NULL, raw_dump); 87 + metricgroup__print(false, true, NULL, raw_dump, details_flag); 88 88 else if ((sep = strchr(argv[i], ':')) != NULL) { 89 89 int sep_idx; 90 90 ··· 102 102 s[sep_idx] = '\0'; 103 103 print_tracepoint_events(s, s + sep_idx + 1, raw_dump); 104 104 print_sdt_events(s, s + sep_idx + 1, raw_dump); 105 - metricgroup__print(true, true, s, raw_dump); 105 + metricgroup__print(true, true, s, raw_dump, details_flag); 106 106 free(s); 107 107 } else { 108 108 if (asprintf(&s, "*%s*", argv[i]) < 0) { ··· 119 119 details_flag); 120 120 print_tracepoint_events(NULL, s, raw_dump); 121 121 print_sdt_events(NULL, s, raw_dump); 122 - metricgroup__print(true, true, NULL, raw_dump); 122 + metricgroup__print(true, true, NULL, raw_dump, details_flag); 123 123 free(s); 124 124 } 125 125 }
+7 -1
tools/perf/util/metricgroup.c
··· 270 270 } 271 271 272 272 void metricgroup__print(bool metrics, bool metricgroups, char *filter, 273 - bool raw) 273 + bool raw, bool details) 274 274 { 275 275 struct pmu_events_map *map = perf_pmu__find_map(NULL); 276 276 struct pmu_event *pe; ··· 329 329 if (asprintf(&s, "%s\n%*s%s]", 330 330 pe->metric_name, 8, "[", pe->desc) < 0) 331 331 return; 332 + 333 + if (details) { 334 + if (asprintf(&s, "%s\n%*s%s]", 335 + s, 8, "[", pe->metric_expr) < 0) 336 + return; 337 + } 332 338 } 333 339 334 340 if (!s)
+2 -1
tools/perf/util/metricgroup.h
··· 27 27 const char *str, 28 28 struct rblist *metric_events); 29 29 30 - void metricgroup__print(bool metrics, bool groups, char *filter, bool raw); 30 + void metricgroup__print(bool metrics, bool groups, char *filter, 31 + bool raw, bool details); 31 32 bool metricgroup__has_metric(const char *metric); 32 33 #endif
+1 -1
tools/perf/util/parse-events.c
··· 2540 2540 2541 2541 print_sdt_events(NULL, NULL, name_only); 2542 2542 2543 - metricgroup__print(true, true, NULL, name_only); 2543 + metricgroup__print(true, true, NULL, name_only, details_flag); 2544 2544 } 2545 2545 2546 2546 int parse_events__is_hardcoded_term(struct parse_events_term *term)