Commit 742d92ff authored by Thomas Richter's avatar Thomas Richter Committed by Arnaldo Carvalho de Melo

perf stat: Add transaction flag (-T) support for s390

The 'perf stat' command line flag -T to display transaction counters is
currently supported for x86 only.

Add support for s390. It is based on the metrics flag -M transaction
using the architecture dependent JSON files. This requires a metric
named "transaction" in the JSON files for the platform.

Introduce a new function metricgroup__has_metric() to check for the
existence of a metric_name transaction.

As suggested by Andi Kleen, this is the new approach to support
transactions counters. Other architectures will follow.

Output before:

  [root@p23lp27 perf]# ./perf stat -T -- sleep 1
  Cannot set up transaction events
  [root@p23lp27 perf]#

Output after:

  [root@s35lp76 perf]# ./perf stat -T -- ~/mytesttx 1 >/tmp/111

   Performance counter stats for '/root/mytesttx 1':

                   1      tx_c_tend           #     13.0 transaction
                   1      tx_nc_tend
                  11      tx_nc_tabort
                   0      tx_c_tabort_special
                   0      tx_c_tabort_no_special

         0.001070109 seconds time elapsed

  [root@s35lp76 perf]#
Suggested-by: default avatarAndi Kleen <ak@linux.intel.com>
Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
Reviewed-by: default avatarHendrik Brueckner <brueckner@linux.ibm.com>
Acked-by: default avatarAndi Kleen <ak@linux.intel.com>
Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Link: http://lkml.kernel.org/r/20180626071701.58190-1-tmricht@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 83eb383e
...@@ -2449,6 +2449,18 @@ static int add_default_attributes(void) ...@@ -2449,6 +2449,18 @@ static int add_default_attributes(void)
return 0; return 0;
if (transaction_run) { 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") && if (pmu_have_event("cpu", "cycles-ct") &&
pmu_have_event("cpu", "el-start")) pmu_have_event("cpu", "el-start"))
err = parse_events(evsel_list, transaction_attrs, err = parse_events(evsel_list, transaction_attrs,
......
...@@ -490,3 +490,25 @@ int metricgroup__parse_groups(const struct option *opt, ...@@ -490,3 +490,25 @@ int metricgroup__parse_groups(const struct option *opt,
metricgroup__free_egroups(&group_list); metricgroup__free_egroups(&group_list);
return ret; return ret;
} }
bool metricgroup__has_metric(const char *metric)
{
struct pmu_events_map *map = perf_pmu__find_map(NULL);
struct pmu_event *pe;
int i;
if (!map)
return false;
for (i = 0; ; i++) {
pe = &map->table[i];
if (!pe->name && !pe->metric_group && !pe->metric_name)
break;
if (!pe->metric_expr)
continue;
if (match_metric(pe->metric_name, metric))
return true;
}
return false;
}
...@@ -28,4 +28,5 @@ int metricgroup__parse_groups(const struct option *opt, ...@@ -28,4 +28,5 @@ int metricgroup__parse_groups(const struct option *opt,
struct rblist *metric_events); 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 metricgroup__has_metric(const char *metric);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment