perf list: Display metric expressions for --details option
authorJiri Olsa <jolsa@kernel.org>
Wed, 13 Feb 2019 12:32:41 +0000 (13:32 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 14 Feb 2019 18:18:09 +0000 (15:18 -0300)
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>
tools/perf/builtin-list.c
tools/perf/util/metricgroup.c
tools/perf/util/metricgroup.h
tools/perf/util/parse-events.c

index ead221e49f003e67d9681e102160e5f9e2e1dbb8..c9f98d00c0e998292d334c92bcfa4186a74dd6bc 100644 (file)
@@ -82,9 +82,9 @@ int cmd_list(int argc, const char **argv)
                else if (strcmp(argv[i], "sdt") == 0)
                        print_sdt_events(NULL, NULL, raw_dump);
                else if (strcmp(argv[i], "metric") == 0)
-                       metricgroup__print(true, false, NULL, raw_dump);
+                       metricgroup__print(true, false, NULL, raw_dump, details_flag);
                else if (strcmp(argv[i], "metricgroup") == 0)
-                       metricgroup__print(false, true, NULL, raw_dump);
+                       metricgroup__print(false, true, NULL, raw_dump, details_flag);
                else if ((sep = strchr(argv[i], ':')) != NULL) {
                        int sep_idx;
 
@@ -102,7 +102,7 @@ int cmd_list(int argc, const char **argv)
                        s[sep_idx] = '\0';
                        print_tracepoint_events(s, s + sep_idx + 1, raw_dump);
                        print_sdt_events(s, s + sep_idx + 1, raw_dump);
-                       metricgroup__print(true, true, s, raw_dump);
+                       metricgroup__print(true, true, s, raw_dump, details_flag);
                        free(s);
                } else {
                        if (asprintf(&s, "*%s*", argv[i]) < 0) {
@@ -119,7 +119,7 @@ int cmd_list(int argc, const char **argv)
                                                details_flag);
                        print_tracepoint_events(NULL, s, raw_dump);
                        print_sdt_events(NULL, s, raw_dump);
-                       metricgroup__print(true, true, NULL, raw_dump);
+                       metricgroup__print(true, true, NULL, raw_dump, details_flag);
                        free(s);
                }
        }
index 8529cbd3955b8a513f8b87221ba4570f1181f27f..b8d864ed4afe033ab0534c8851bdaa504ed54007 100644 (file)
@@ -270,7 +270,7 @@ static void metricgroup__print_strlist(struct strlist *metrics, bool raw)
 }
 
 void metricgroup__print(bool metrics, bool metricgroups, char *filter,
-                       bool raw)
+                       bool raw, bool details)
 {
        struct pmu_events_map *map = perf_pmu__find_map(NULL);
        struct pmu_event *pe;
@@ -329,6 +329,12 @@ void metricgroup__print(bool metrics, bool metricgroups, char *filter,
                                        if (asprintf(&s, "%s\n%*s%s]",
                                                     pe->metric_name, 8, "[", pe->desc) < 0)
                                                return;
+
+                                       if (details) {
+                                               if (asprintf(&s, "%s\n%*s%s]",
+                                                            s, 8, "[", pe->metric_expr) < 0)
+                                                       return;
+                                       }
                                }
 
                                if (!s)
index 8a155dba0581e5d3c7bad97a946c222fba898852..5c52097a5c63ac69f1cfe5a33a42e1c828043127 100644 (file)
@@ -27,6 +27,7 @@ int metricgroup__parse_groups(const struct option *opt,
                        const char *str,
                        struct rblist *metric_events);
 
-void metricgroup__print(bool metrics, bool groups, char *filter, bool raw);
+void metricgroup__print(bool metrics, bool groups, char *filter,
+                       bool raw, bool details);
 bool metricgroup__has_metric(const char *metric);
 #endif
index 920e1e6551dd8b9d56787104999edf6a5a1825ac..4dcc01b2532c842dddc720d31b528f6be5532c02 100644 (file)
@@ -2540,7 +2540,7 @@ void print_events(const char *event_glob, bool name_only, bool quiet_flag,
 
        print_sdt_events(NULL, NULL, name_only);
 
-       metricgroup__print(true, true, NULL, name_only);
+       metricgroup__print(true, true, NULL, name_only, details_flag);
 }
 
 int parse_events__is_hardcoded_term(struct parse_events_term *term)