perf stat: Add aggr_mode argument to print_shadow_stats function
[firefly-linux-kernel-4.4.55.git] / tools / perf / builtin-stat.c
index cca100dc5fd010850d5c275048d2ad7541e61fbb..50918dc9fb319243ea977c83ad02d415cab5fe5b 100644 (file)
@@ -73,8 +73,8 @@ static void print_counter(struct perf_evsel *counter, char *prefix);
 static void print_aggr(char *prefix);
 
 /* Default events used for perf stat -T */
-static const char * const transaction_attrs[] = {
-       "task-clock",
+static const char *transaction_attrs = {
+       "task-clock,"
        "{"
        "instructions,"
        "cycles,"
@@ -86,8 +86,8 @@ static const char * const transaction_attrs[] = {
 };
 
 /* More limited version when the CPU does not have all events. */
-static const char * const transaction_limited_attrs[] = {
-       "task-clock",
+static const char * transaction_limited_attrs = {
+       "task-clock,"
        "{"
        "instructions,"
        "cycles,"
@@ -96,17 +96,6 @@ static const char * const transaction_limited_attrs[] = {
        "}"
 };
 
-/* must match transaction_attrs and the beginning limited_attrs */
-enum {
-       T_TASK_CLOCK,
-       T_INSTRUCTIONS,
-       T_CYCLES,
-       T_CYCLES_IN_TX,
-       T_TRANSACTION_START,
-       T_ELISION_START,
-       T_CYCLES_IN_TX_CP,
-};
-
 static struct perf_evlist      *evsel_list;
 
 static struct target target = {
@@ -147,10 +136,6 @@ static int                 (*aggr_get_id)(struct cpu_map *m, int cpu);
 
 static volatile int done = 0;
 
-struct perf_stat {
-       struct stats      res_stats[3];
-};
-
 static inline void diff_timespec(struct timespec *r, struct timespec *a,
                                 struct timespec *b)
 {
@@ -180,6 +165,8 @@ static void perf_evsel__reset_stat_priv(struct perf_evsel *evsel)
 
        for (i = 0; i < 3; i++)
                init_stats(&ps->res_stats[i]);
+
+       perf_stat_evsel_id_init(evsel);
 }
 
 static int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel)
@@ -250,7 +237,10 @@ out_free:
 enum {
        CTX_BIT_USER    = 1 << 0,
        CTX_BIT_KERNEL  = 1 << 1,
-       CTX_BIT_MAX     = 1 << 2,
+       CTX_BIT_HV      = 1 << 2,
+       CTX_BIT_HOST    = 1 << 3,
+       CTX_BIT_IDLE    = 1 << 4,
+       CTX_BIT_MAX     = 1 << 5,
 };
 
 #define NUM_CTX CTX_BIT_MAX
@@ -279,18 +269,18 @@ static int evsel_context(struct perf_evsel *evsel)
                ctx |= CTX_BIT_KERNEL;
        if (evsel->attr.exclude_user)
                ctx |= CTX_BIT_USER;
+       if (evsel->attr.exclude_hv)
+               ctx |= CTX_BIT_HV;
+       if (evsel->attr.exclude_host)
+               ctx |= CTX_BIT_HOST;
+       if (evsel->attr.exclude_idle)
+               ctx |= CTX_BIT_IDLE;
+
        return ctx;
 }
 
-static void perf_stat__reset_stats(struct perf_evlist *evlist)
+static void reset_shadow_stats(void)
 {
-       struct perf_evsel *evsel;
-
-       evlist__for_each(evlist, evsel) {
-               perf_evsel__reset_stat_priv(evsel);
-               perf_evsel__reset_counts(evsel, perf_evsel__nr_cpus(evsel));
-       }
-
        memset(runtime_nsecs_stats, 0, sizeof(runtime_nsecs_stats));
        memset(runtime_cycles_stats, 0, sizeof(runtime_cycles_stats));
        memset(runtime_stalled_cycles_front_stats, 0, sizeof(runtime_stalled_cycles_front_stats));
@@ -310,6 +300,18 @@ static void perf_stat__reset_stats(struct perf_evlist *evlist)
        memset(&walltime_nsecs_stats, 0, sizeof(walltime_nsecs_stats));
 }
 
+static void perf_stat__reset_stats(struct perf_evlist *evlist)
+{
+       struct perf_evsel *evsel;
+
+       evlist__for_each(evlist, evsel) {
+               perf_evsel__reset_stat_priv(evsel);
+               perf_evsel__reset_counts(evsel, perf_evsel__nr_cpus(evsel));
+       }
+
+       reset_shadow_stats();
+}
+
 static int create_perf_stat_counter(struct perf_evsel *evsel)
 {
        struct perf_event_attr *attr = &evsel->attr;
@@ -344,29 +346,6 @@ static inline int nsec_counter(struct perf_evsel *evsel)
        return 0;
 }
 
-static struct perf_evsel *nth_evsel(int n)
-{
-       static struct perf_evsel **array;
-       static int array_len;
-       struct perf_evsel *ev;
-       int j;
-
-       /* Assumes this only called when evsel_list does not change anymore. */
-       if (!array) {
-               evlist__for_each(evsel_list, ev)
-                       array_len++;
-               array = malloc(array_len * sizeof(void *));
-               if (!array)
-                       exit(ENOMEM);
-               j = 0;
-               evlist__for_each(evsel_list, ev)
-                       array[j++] = ev;
-       }
-       if (n < array_len)
-               return array[n];
-       return NULL;
-}
-
 /*
  * Update various tracking values we maintain to print
  * more semantic information such as miss/hit ratios,
@@ -381,14 +360,11 @@ static void update_shadow_stats(struct perf_evsel *counter, u64 *count,
                update_stats(&runtime_nsecs_stats[cpu], count[0]);
        else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES))
                update_stats(&runtime_cycles_stats[ctx][cpu], count[0]);
-       else if (transaction_run &&
-                perf_evsel__cmp(counter, nth_evsel(T_CYCLES_IN_TX)))
+       else if (perf_stat_evsel__is(counter, CYCLES_IN_TX))
                update_stats(&runtime_transaction_stats[ctx][cpu], count[0]);
-       else if (transaction_run &&
-                perf_evsel__cmp(counter, nth_evsel(T_TRANSACTION_START)))
+       else if (perf_stat_evsel__is(counter, TRANSACTION_START))
                update_stats(&runtime_transaction_stats[ctx][cpu], count[0]);
-       else if (transaction_run &&
-                perf_evsel__cmp(counter, nth_evsel(T_ELISION_START)))
+       else if (perf_stat_evsel__is(counter, ELISION_START))
                update_stats(&runtime_elision_stats[ctx][cpu], count[0]);
        else if (perf_evsel__match(counter, HARDWARE, HW_STALLED_CYCLES_FRONTEND))
                update_stats(&runtime_stalled_cycles_front_stats[ctx][cpu], count[0]);
@@ -923,7 +899,7 @@ static const char *get_ratio_color(enum grc_type type, double ratio)
        return color;
 }
 
-static void print_stalled_cycles_frontend(int cpu,
+static void print_stalled_cycles_frontend(FILE *out, int cpu,
                                          struct perf_evsel *evsel
                                          __maybe_unused, double avg)
 {
@@ -938,12 +914,12 @@ static void print_stalled_cycles_frontend(int cpu,
 
        color = get_ratio_color(GRC_STALLED_CYCLES_FE, ratio);
 
-       fprintf(output, " #  ");
-       color_fprintf(output, color, "%6.2f%%", ratio);
-       fprintf(output, " frontend cycles idle   ");
+       fprintf(out, " #  ");
+       color_fprintf(out, color, "%6.2f%%", ratio);
+       fprintf(out, " frontend cycles idle   ");
 }
 
-static void print_stalled_cycles_backend(int cpu,
+static void print_stalled_cycles_backend(FILE *out, int cpu,
                                         struct perf_evsel *evsel
                                         __maybe_unused, double avg)
 {
@@ -958,12 +934,12 @@ static void print_stalled_cycles_backend(int cpu,
 
        color = get_ratio_color(GRC_STALLED_CYCLES_BE, ratio);
 
-       fprintf(output, " #  ");
-       color_fprintf(output, color, "%6.2f%%", ratio);
-       fprintf(output, " backend  cycles idle   ");
+       fprintf(out, " #  ");
+       color_fprintf(out, color, "%6.2f%%", ratio);
+       fprintf(out, " backend  cycles idle   ");
 }
 
-static void print_branch_misses(int cpu,
+static void print_branch_misses(FILE *out, int cpu,
                                struct perf_evsel *evsel __maybe_unused,
                                double avg)
 {
@@ -978,12 +954,12 @@ static void print_branch_misses(int cpu,
 
        color = get_ratio_color(GRC_CACHE_MISSES, ratio);
 
-       fprintf(output, " #  ");
-       color_fprintf(output, color, "%6.2f%%", ratio);
-       fprintf(output, " of all branches        ");
+       fprintf(out, " #  ");
+       color_fprintf(out, color, "%6.2f%%", ratio);
+       fprintf(out, " of all branches        ");
 }
 
-static void print_l1_dcache_misses(int cpu,
+static void print_l1_dcache_misses(FILE *out, int cpu,
                                   struct perf_evsel *evsel __maybe_unused,
                                   double avg)
 {
@@ -998,12 +974,12 @@ static void print_l1_dcache_misses(int cpu,
 
        color = get_ratio_color(GRC_CACHE_MISSES, ratio);
 
-       fprintf(output, " #  ");
-       color_fprintf(output, color, "%6.2f%%", ratio);
-       fprintf(output, " of all L1-dcache hits  ");
+       fprintf(out, " #  ");
+       color_fprintf(out, color, "%6.2f%%", ratio);
+       fprintf(out, " of all L1-dcache hits  ");
 }
 
-static void print_l1_icache_misses(int cpu,
+static void print_l1_icache_misses(FILE *out, int cpu,
                                   struct perf_evsel *evsel __maybe_unused,
                                   double avg)
 {
@@ -1018,12 +994,12 @@ static void print_l1_icache_misses(int cpu,
 
        color = get_ratio_color(GRC_CACHE_MISSES, ratio);
 
-       fprintf(output, " #  ");
-       color_fprintf(output, color, "%6.2f%%", ratio);
-       fprintf(output, " of all L1-icache hits  ");
+       fprintf(out, " #  ");
+       color_fprintf(out, color, "%6.2f%%", ratio);
+       fprintf(out, " of all L1-icache hits  ");
 }
 
-static void print_dtlb_cache_misses(int cpu,
+static void print_dtlb_cache_misses(FILE *out, int cpu,
                                    struct perf_evsel *evsel __maybe_unused,
                                    double avg)
 {
@@ -1038,12 +1014,12 @@ static void print_dtlb_cache_misses(int cpu,
 
        color = get_ratio_color(GRC_CACHE_MISSES, ratio);
 
-       fprintf(output, " #  ");
-       color_fprintf(output, color, "%6.2f%%", ratio);
-       fprintf(output, " of all dTLB cache hits ");
+       fprintf(out, " #  ");
+       color_fprintf(out, color, "%6.2f%%", ratio);
+       fprintf(out, " of all dTLB cache hits ");
 }
 
-static void print_itlb_cache_misses(int cpu,
+static void print_itlb_cache_misses(FILE *out, int cpu,
                                    struct perf_evsel *evsel __maybe_unused,
                                    double avg)
 {
@@ -1058,12 +1034,12 @@ static void print_itlb_cache_misses(int cpu,
 
        color = get_ratio_color(GRC_CACHE_MISSES, ratio);
 
-       fprintf(output, " #  ");
-       color_fprintf(output, color, "%6.2f%%", ratio);
-       fprintf(output, " of all iTLB cache hits ");
+       fprintf(out, " #  ");
+       color_fprintf(out, color, "%6.2f%%", ratio);
+       fprintf(out, " of all iTLB cache hits ");
 }
 
-static void print_ll_cache_misses(int cpu,
+static void print_ll_cache_misses(FILE *out, int cpu,
                                  struct perf_evsel *evsel __maybe_unused,
                                  double avg)
 {
@@ -1078,105 +1054,74 @@ static void print_ll_cache_misses(int cpu,
 
        color = get_ratio_color(GRC_CACHE_MISSES, ratio);
 
-       fprintf(output, " #  ");
-       color_fprintf(output, color, "%6.2f%%", ratio);
-       fprintf(output, " of all LL-cache hits   ");
+       fprintf(out, " #  ");
+       color_fprintf(out, color, "%6.2f%%", ratio);
+       fprintf(out, " of all LL-cache hits   ");
 }
 
-static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
+static void print_shadow_stats(FILE *out, struct perf_evsel *evsel,
+                              double avg, int cpu, enum aggr_mode aggr)
 {
        double total, ratio = 0.0, total2;
-       double sc =  evsel->scale;
-       const char *fmt;
-       int cpu = cpu_map__id_to_cpu(id);
        int ctx = evsel_context(evsel);
 
-       if (csv_output) {
-               fmt = sc != 1.0 ?  "%.2f%s" : "%.0f%s";
-       } else {
-               if (big_num)
-                       fmt = sc != 1.0 ? "%'18.2f%s" : "%'18.0f%s";
-               else
-                       fmt = sc != 1.0 ? "%18.2f%s" : "%18.0f%s";
-       }
-
-       aggr_printout(evsel, id, nr);
-
-       if (aggr_mode == AGGR_GLOBAL)
-               cpu = 0;
-
-       fprintf(output, fmt, avg, csv_sep);
-
-       if (evsel->unit)
-               fprintf(output, "%-*s%s",
-                       csv_output ? 0 : unit_width,
-                       evsel->unit, csv_sep);
-
-       fprintf(output, "%-*s", csv_output ? 0 : 25, perf_evsel__name(evsel));
-
-       if (evsel->cgrp)
-               fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
-
-       if (csv_output || interval)
-               return;
-
        if (perf_evsel__match(evsel, HARDWARE, HW_INSTRUCTIONS)) {
                total = avg_stats(&runtime_cycles_stats[ctx][cpu]);
                if (total) {
                        ratio = avg / total;
-                       fprintf(output, " #   %5.2f  insns per cycle        ", ratio);
+                       fprintf(out, " #   %5.2f  insns per cycle        ", ratio);
                } else {
-                       fprintf(output, "                                   ");
+                       fprintf(out, "                                   ");
                }
                total = avg_stats(&runtime_stalled_cycles_front_stats[ctx][cpu]);
                total = max(total, avg_stats(&runtime_stalled_cycles_back_stats[ctx][cpu]));
 
                if (total && avg) {
                        ratio = total / avg;
-                       fprintf(output, "\n");
-                       if (aggr_mode == AGGR_NONE)
-                               fprintf(output, "        ");
-                       fprintf(output, "                                                  #   %5.2f  stalled cycles per insn", ratio);
+                       fprintf(out, "\n");
+                       if (aggr == AGGR_NONE)
+                               fprintf(out, "        ");
+                       fprintf(out, "                                                  #   %5.2f  stalled cycles per insn", ratio);
                }
 
        } else if (perf_evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES) &&
                        runtime_branches_stats[ctx][cpu].n != 0) {
-               print_branch_misses(cpu, evsel, avg);
+               print_branch_misses(out, cpu, evsel, avg);
        } else if (
                evsel->attr.type == PERF_TYPE_HW_CACHE &&
                evsel->attr.config ==  ( PERF_COUNT_HW_CACHE_L1D |
                                        ((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
                                        ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) &&
                        runtime_l1_dcache_stats[ctx][cpu].n != 0) {
-               print_l1_dcache_misses(cpu, evsel, avg);
+               print_l1_dcache_misses(out, cpu, evsel, avg);
        } else if (
                evsel->attr.type == PERF_TYPE_HW_CACHE &&
                evsel->attr.config ==  ( PERF_COUNT_HW_CACHE_L1I |
                                        ((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
                                        ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) &&
                        runtime_l1_icache_stats[ctx][cpu].n != 0) {
-               print_l1_icache_misses(cpu, evsel, avg);
+               print_l1_icache_misses(out, cpu, evsel, avg);
        } else if (
                evsel->attr.type == PERF_TYPE_HW_CACHE &&
                evsel->attr.config ==  ( PERF_COUNT_HW_CACHE_DTLB |
                                        ((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
                                        ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) &&
                        runtime_dtlb_cache_stats[ctx][cpu].n != 0) {
-               print_dtlb_cache_misses(cpu, evsel, avg);
+               print_dtlb_cache_misses(out, cpu, evsel, avg);
        } else if (
                evsel->attr.type == PERF_TYPE_HW_CACHE &&
                evsel->attr.config ==  ( PERF_COUNT_HW_CACHE_ITLB |
                                        ((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
                                        ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) &&
                        runtime_itlb_cache_stats[ctx][cpu].n != 0) {
-               print_itlb_cache_misses(cpu, evsel, avg);
+               print_itlb_cache_misses(out, cpu, evsel, avg);
        } else if (
                evsel->attr.type == PERF_TYPE_HW_CACHE &&
                evsel->attr.config ==  ( PERF_COUNT_HW_CACHE_LL |
                                        ((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
                                        ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) &&
                        runtime_ll_cache_stats[ctx][cpu].n != 0) {
-               print_ll_cache_misses(cpu, evsel, avg);
+               print_ll_cache_misses(out, cpu, evsel, avg);
        } else if (perf_evsel__match(evsel, HARDWARE, HW_CACHE_MISSES) &&
                        runtime_cacherefs_stats[ctx][cpu].n != 0) {
                total = avg_stats(&runtime_cacherefs_stats[ctx][cpu]);
@@ -1184,40 +1129,37 @@ static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
                if (total)
                        ratio = avg * 100 / total;
 
-               fprintf(output, " # %8.3f %% of all cache refs    ", ratio);
+               fprintf(out, " # %8.3f %% of all cache refs    ", ratio);
 
        } else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES_FRONTEND)) {
-               print_stalled_cycles_frontend(cpu, evsel, avg);
+               print_stalled_cycles_frontend(out, cpu, evsel, avg);
        } else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES_BACKEND)) {
-               print_stalled_cycles_backend(cpu, evsel, avg);
+               print_stalled_cycles_backend(out, cpu, evsel, avg);
        } else if (perf_evsel__match(evsel, HARDWARE, HW_CPU_CYCLES)) {
                total = avg_stats(&runtime_nsecs_stats[cpu]);
 
                if (total) {
                        ratio = avg / total;
-                       fprintf(output, " # %8.3f GHz                    ", ratio);
+                       fprintf(out, " # %8.3f GHz                    ", ratio);
                } else {
-                       fprintf(output, "                                   ");
+                       fprintf(out, "                                   ");
                }
-       } else if (transaction_run &&
-                  perf_evsel__cmp(evsel, nth_evsel(T_CYCLES_IN_TX))) {
+       } else if (perf_stat_evsel__is(evsel, CYCLES_IN_TX)) {
                total = avg_stats(&runtime_cycles_stats[ctx][cpu]);
                if (total)
-                       fprintf(output,
+                       fprintf(out,
                                " #   %5.2f%% transactional cycles   ",
                                100.0 * (avg / total));
-       } else if (transaction_run &&
-                  perf_evsel__cmp(evsel, nth_evsel(T_CYCLES_IN_TX_CP))) {
+       } else if (perf_stat_evsel__is(evsel, CYCLES_IN_TX_CP)) {
                total = avg_stats(&runtime_cycles_stats[ctx][cpu]);
                total2 = avg_stats(&runtime_cycles_in_tx_stats[ctx][cpu]);
                if (total2 < avg)
                        total2 = avg;
                if (total)
-                       fprintf(output,
+                       fprintf(out,
                                " #   %5.2f%% aborted cycles         ",
                                100.0 * ((total2-avg) / total));
-       } else if (transaction_run &&
-                  perf_evsel__cmp(evsel, nth_evsel(T_TRANSACTION_START)) &&
+       } else if (perf_stat_evsel__is(evsel, TRANSACTION_START) &&
                   avg > 0 &&
                   runtime_cycles_in_tx_stats[ctx][cpu].n != 0) {
                total = avg_stats(&runtime_cycles_in_tx_stats[ctx][cpu]);
@@ -1225,9 +1167,8 @@ static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
                if (total)
                        ratio = total / avg;
 
-               fprintf(output, " # %8.0f cycles / transaction   ", ratio);
-       } else if (transaction_run &&
-                  perf_evsel__cmp(evsel, nth_evsel(T_ELISION_START)) &&
+               fprintf(out, " # %8.0f cycles / transaction   ", ratio);
+       } else if (perf_stat_evsel__is(evsel, ELISION_START) &&
                   avg > 0 &&
                   runtime_cycles_in_tx_stats[ctx][cpu].n != 0) {
                total = avg_stats(&runtime_cycles_in_tx_stats[ctx][cpu]);
@@ -1235,7 +1176,7 @@ static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
                if (total)
                        ratio = total / avg;
 
-               fprintf(output, " # %8.0f cycles / elision       ", ratio);
+               fprintf(out, " # %8.0f cycles / elision       ", ratio);
        } else if (runtime_nsecs_stats[cpu].n != 0) {
                char unit = 'M';
 
@@ -1248,12 +1189,50 @@ static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
                        unit = 'K';
                }
 
-               fprintf(output, " # %8.3f %c/sec                  ", ratio, unit);
+               fprintf(out, " # %8.3f %c/sec                  ", ratio, unit);
        } else {
-               fprintf(output, "                                   ");
+               fprintf(out, "                                   ");
        }
 }
 
+static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
+{
+       double sc =  evsel->scale;
+       const char *fmt;
+       int cpu = cpu_map__id_to_cpu(id);
+
+       if (csv_output) {
+               fmt = sc != 1.0 ?  "%.2f%s" : "%.0f%s";
+       } else {
+               if (big_num)
+                       fmt = sc != 1.0 ? "%'18.2f%s" : "%'18.0f%s";
+               else
+                       fmt = sc != 1.0 ? "%18.2f%s" : "%18.0f%s";
+       }
+
+       aggr_printout(evsel, id, nr);
+
+       if (aggr_mode == AGGR_GLOBAL)
+               cpu = 0;
+
+       fprintf(output, fmt, avg, csv_sep);
+
+       if (evsel->unit)
+               fprintf(output, "%-*s%s",
+                       csv_output ? 0 : unit_width,
+                       evsel->unit, csv_sep);
+
+       fprintf(output, "%-*s", csv_output ? 0 : 25, perf_evsel__name(evsel));
+
+       if (evsel->cgrp)
+               fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
+
+       if (csv_output || interval)
+               return;
+
+       print_shadow_stats(output, evsel, avg, cpu, aggr_mode);
+}
+
 static void print_aggr(char *prefix)
 {
        struct perf_evsel *counter;
@@ -1566,17 +1545,6 @@ static int perf_stat_init_aggr_mode(void)
        return 0;
 }
 
-static int setup_events(const char * const *attrs, unsigned len)
-{
-       unsigned i;
-
-       for (i = 0; i < len; i++) {
-               if (parse_events(evsel_list, attrs[i], NULL))
-                       return -1;
-       }
-       return 0;
-}
-
 /*
  * Add default attributes, if there were no attributes specified or
  * if -d/--detailed, -d -d or -d -d -d is used:
@@ -1698,12 +1666,10 @@ static int add_default_attributes(void)
                int err;
                if (pmu_have_event("cpu", "cycles-ct") &&
                    pmu_have_event("cpu", "el-start"))
-                       err = setup_events(transaction_attrs,
-                                       ARRAY_SIZE(transaction_attrs));
+                       err = parse_events(evsel_list, transaction_attrs, NULL);
                else
-                       err = setup_events(transaction_limited_attrs,
-                                ARRAY_SIZE(transaction_limited_attrs));
-               if (err < 0) {
+                       err = parse_events(evsel_list, transaction_limited_attrs, NULL);
+               if (err) {
                        fprintf(stderr, "Cannot set up transaction events\n");
                        return -1;
                }