Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1216958imm; Wed, 25 Jul 2018 13:46:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcsJirg5kOltnFdNvL6ntKR2yAX0kd1vNJVHlT1YAJCyeWig9m2R800UcQIHnJ6lnxUQ6pv X-Received: by 2002:a17:902:6ac3:: with SMTP id i3-v6mr22496946plt.252.1532551609019; Wed, 25 Jul 2018 13:46:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532551608; cv=none; d=google.com; s=arc-20160816; b=LnIbGQp3GqtLGmcxXmdRSP15UFJYFF4yxxCD4tVmorb9jF1HgU9QicPrKaNQP77aBL dfNsDqo5Pdr990ZLoCCi+YBCSiXrpiD0W5I/C4FFc44rkxY8KvfteX//iJegwZKfKfKH jnUnz4D/QL03aZO/JXcooSBbDY/bNQ+z6I9jEVkNpmcNk2zrdTzaHx5EjVnkM2TYt8ef iciTupIa2Ri08jGb0C7lL7F37q/dyQwA9mEFqu+ZDNYtSMkd7Ys6GW+4cphQmjLBoGEP e7VkqRQzrWksjexpgp+aOxa5z8GzThzMA/6W8J3VH8OU/DhJL3IH12s5j4JthMQhczid jyrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=YoLvik/MdFGYPfB/T8kaV8LKyL9VpMjA47Vu+i9+vbM=; b=b1s8YWwL5XxTUL4RNUED8JZpdYPrA+8l9B415t/gUtn47zWB1plfrOnLO7LDkDY6xu sWM1NO4uvVmnfWs3PWRWmLF6SfwCdfYkrTibyf/CioIbzQHi+uA5E6dXma5N/ThiVs2t rxoGHVSE62PkPNSGYO83cKzTsr06zOAkiAblTEQXkNCBOw/ackK286DPxIPxbO/9WyLi ab2JMzuYFUXyr4EC6LQxEVepKI6GiRyE4AYNpN+7RzCx1tClNdPkRiQU8fw8a34NOSlu UajMAIIri5OfeRiwCzSrIBsTb1HSS4Rw3BQ/oO/1CyTDBfZ/xjQ1hdMXvU1FDVpNOS+G Z02g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p7-v6si12988399plo.284.2018.07.25.13.46.34; Wed, 25 Jul 2018 13:46:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731400AbeGYV7D (ORCPT + 99 others); Wed, 25 Jul 2018 17:59:03 -0400 Received: from terminus.zytor.com ([198.137.202.136]:49347 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730357AbeGYV7D (ORCPT ); Wed, 25 Jul 2018 17:59:03 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w6PKhWIa498895 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 25 Jul 2018 13:43:32 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w6PKhVfI498890; Wed, 25 Jul 2018 13:43:31 -0700 Date: Wed, 25 Jul 2018 13:43:31 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Thomas Richter Message-ID: Cc: tmricht@linux.ibm.com, schwidefsky@de.ibm.com, mingo@kernel.org, heiko.carstens@de.ibm.com, acme@redhat.com, jolsa@redhat.com, brueckner@linux.ibm.com, hpa@zytor.com, linux-kernel@vger.kernel.org, ak@linux.intel.com, tglx@linutronix.de Reply-To: schwidefsky@de.ibm.com, mingo@kernel.org, tmricht@linux.ibm.com, acme@redhat.com, heiko.carstens@de.ibm.com, jolsa@redhat.com, hpa@zytor.com, brueckner@linux.ibm.com, ak@linux.intel.com, linux-kernel@vger.kernel.org, tglx@linutronix.de In-Reply-To: <20180626071701.58190-1-tmricht@linux.ibm.com> References: <20180626071701.58190-1-tmricht@linux.ibm.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf stat: Add transaction flag (-T) support for s390 Git-Commit-ID: 742d92ff219f3aa7a67c184a57acfa8d88936cd6 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_48_96 autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 742d92ff219f3aa7a67c184a57acfa8d88936cd6 Gitweb: https://git.kernel.org/tip/742d92ff219f3aa7a67c184a57acfa8d88936cd6 Author: Thomas Richter AuthorDate: Tue, 26 Jun 2018 09:17:01 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 24 Jul 2018 14:49:37 -0300 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: Andi Kleen Signed-off-by: Thomas Richter Reviewed-by: Hendrik Brueckner Acked-by: Andi Kleen Acked-by: Jiri Olsa Cc: Heiko Carstens Cc: Martin Schwidefsky Link: http://lkml.kernel.org/r/20180626071701.58190-1-tmricht@linux.ibm.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-stat.c | 12 ++++++++++++ tools/perf/util/metricgroup.c | 22 ++++++++++++++++++++++ tools/perf/util/metricgroup.h | 1 + 3 files changed, 35 insertions(+) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 05be023c3f0e..dfd13d6e2931 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -2449,6 +2449,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, diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 1ddc3d1d0147..96eab4ec34ff 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -490,3 +490,25 @@ out: metricgroup__free_egroups(&group_list); 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; +} diff --git a/tools/perf/util/metricgroup.h b/tools/perf/util/metricgroup.h index 06854e125ee7..8a155dba0581 100644 --- a/tools/perf/util/metricgroup.h +++ b/tools/perf/util/metricgroup.h @@ -28,4 +28,5 @@ int metricgroup__parse_groups(const struct option *opt, struct rblist *metric_events); void metricgroup__print(bool metrics, bool groups, char *filter, bool raw); +bool metricgroup__has_metric(const char *metric); #endif