]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - tools/perf/builtin-stat.c
tools headers uapi: Update tools's copy of asm-generic/unistd.h
[linux.git] / tools / perf / builtin-stat.c
index 22547a490e1f9ec4e20f18a1b0483c0b2e5b0f32..d097b5b47eb81e16b83a8a37f3385aeea124a0ed 100644 (file)
@@ -296,18 +296,6 @@ static int create_perf_stat_counter(struct perf_evsel *evsel)
        return perf_evsel__open_per_thread(evsel, evsel_list->threads);
 }
 
-/*
- * Does the counter have nsecs as a unit?
- */
-static inline int nsec_counter(struct perf_evsel *evsel)
-{
-       if (perf_evsel__match(evsel, SOFTWARE, SW_CPU_CLOCK) ||
-           perf_evsel__match(evsel, SOFTWARE, SW_TASK_CLOCK))
-               return 1;
-
-       return 0;
-}
-
 static int process_synthesized_event(struct perf_tool *tool __maybe_unused,
                                     union perf_event *event,
                                     struct perf_sample *sample __maybe_unused,
@@ -1058,34 +1046,6 @@ static void print_metric_header(void *ctx, const char *color __maybe_unused,
                fprintf(os->fh, "%*s ", metric_only_len, unit);
 }
 
-static void nsec_printout(int id, int nr, struct perf_evsel *evsel, double avg)
-{
-       FILE *output = stat_config.output;
-       double msecs = avg / NSEC_PER_MSEC;
-       const char *fmt_v, *fmt_n;
-       char name[25];
-
-       fmt_v = csv_output ? "%.6f%s" : "%18.6f%s";
-       fmt_n = csv_output ? "%s" : "%-25s";
-
-       aggr_printout(evsel, id, nr);
-
-       scnprintf(name, sizeof(name), "%s%s",
-                 perf_evsel__name(evsel), csv_output ? "" : " (msec)");
-
-       fprintf(output, fmt_v, msecs, csv_sep);
-
-       if (csv_output)
-               fprintf(output, "%s%s", evsel->unit, csv_sep);
-       else
-               fprintf(output, "%-*s%s", unit_width, evsel->unit, csv_sep);
-
-       fprintf(output, fmt_n, name);
-
-       if (evsel->cgrp)
-               fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
-}
-
 static int first_shadow_cpu(struct perf_evsel *evsel, int id)
 {
        int i;
@@ -1241,11 +1201,7 @@ static void printout(int id, int nr, struct perf_evsel *counter, double uval,
                return;
        }
 
-       if (metric_only)
-               /* nothing */;
-       else if (nsec_counter(counter))
-               nsec_printout(id, nr, counter, uval);
-       else
+       if (!metric_only)
                abs_printout(id, nr, counter, uval);
 
        out.print_metric = pm;
@@ -1331,7 +1287,7 @@ static void collect_all_aliases(struct perf_evsel *counter,
                    alias->scale != counter->scale ||
                    alias->cgrp != counter->cgrp ||
                    strcmp(alias->unit, counter->unit) ||
-                   nsec_counter(alias) != nsec_counter(counter))
+                   perf_evsel__is_clock(alias) != perf_evsel__is_clock(counter))
                        break;
                alias->merged_stat = true;
                cb(alias, data, false);
@@ -1742,7 +1698,7 @@ static void print_interval(char *prefix, struct timespec *ts)
                }
        }
 
-       if ((num_print_interval == 0 && metric_only) || interval_clear)
+       if ((num_print_interval == 0 || interval_clear) && metric_only)
                print_metric_headers(" ", true);
        if (++num_print_interval == 25)
                num_print_interval = 0;
@@ -2449,6 +2405,18 @@ static int add_default_attributes(void)
                return 0;
 
        if (transaction_run) {
+               /* Handle -T as -M transaction. Once platform specific metrics
+                * support has been added to the json files, all archictures
+                * will use this approach. To determine transaction support
+                * on an architecture test for such a metric name.
+                */
+               if (metricgroup__has_metric("transaction")) {
+                       struct option opt = { .value = &evsel_list };
+
+                       return metricgroup__parse_groups(&opt, "transaction",
+                                                        &metric_events);
+               }
+
                if (pmu_have_event("cpu", "cycles-ct") &&
                    pmu_have_event("cpu", "el-start"))
                        err = parse_events(evsel_list, transaction_attrs,