Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp4798223imm; Tue, 26 Jun 2018 00:19:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIVpBkDVBFiy1va8USTj8VOwlJF1ebVVXV82BVtXZW2UgWGae2AhszU8H5B1GeB16SJKM0A X-Received: by 2002:a65:65ca:: with SMTP id y10-v6mr308860pgv.359.1529997550995; Tue, 26 Jun 2018 00:19:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529997550; cv=none; d=google.com; s=arc-20160816; b=RFQIPvWv7SfkNssGUToh8nz61SJaA9sM6TE+RXdezD5mJqm9MEMN94Xr6O/w21iztk L0SLozWKiGfE04uKvc9of0nyzhYFgfgDOBC7cgHxwHsYuTIJ60GT/XyrGbhtfqM2UklO XejxgQso+cDOqInYu+o3o2ceVVW9QtZG8NymviCB58Ne5Ry1DKGCk//G5vQui2mb4L/q uK5gOfxrL830RM4H3j+3Qd3w+YkicTqD9u1lNeYYUWZFAcQIkXzBfUnfnqxGmJ/uRGm2 cSsUBOB4qsZeu92ygK/gRss1gYKggO46Ho9hRZDpw0Pa8NoGOdtFEpLVAVdfsJmMdS7w aMNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=iCO3xmr7BoY0TPUEpLBNkVmllemfasEC/B4wyInBR2E=; b=epDMXqdsKapH6lYaBIBLYt0S2f9I9M7hWdvfcvvlTN4juibeYapToGo0pYMNLisk70 QjlqidEo82XL45pks8/2xQcyRx2Vlj0KLWZZDaAIUIF5DAjGL84/KPPhxfXE9pRF8Caw fts1rEjIazk0l0vFuCBVbgSdvrjXCF7jgWoSpNJmD5YoeC1H+I8lyPMOzssHy1W4rNZW 2dBFYZPJTqIMP0EnN25fnF4PV+fChzCr2Q8MDcieChLHTKYmGCyhwjz/6kI4GW04raXM MFnRjAVoO3Ta5hScZk8cGM0GGgNKUHwMUvfJj7+v1In6dmqk/pZoHkbCHYKt/oz6roI8 589g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w135-v6si1055667pff.18.2018.06.26.00.18.56; Tue, 26 Jun 2018 00:19:10 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752467AbeFZHRU (ORCPT + 99 others); Tue, 26 Jun 2018 03:17:20 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:56754 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752402AbeFZHRS (ORCPT ); Tue, 26 Jun 2018 03:17:18 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5Q7BH8p110320 for ; Tue, 26 Jun 2018 03:17:17 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jufb5kxj0-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 26 Jun 2018 03:17:17 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 26 Jun 2018 08:17:15 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 26 Jun 2018 08:17:12 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5Q7HBpL30736536 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 26 Jun 2018 07:17:12 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4A5275205F; Tue, 26 Jun 2018 08:17:06 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 03DE65204F; Tue, 26 Jun 2018 08:17:05 +0100 (BST) From: Thomas Richter To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, acme@kernel.org Cc: brueckner@linux.vnet.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, ak@linux.intel.com, jolsa@redhat.com, Thomas Richter Subject: [PATCH 4/4 v4] perf stat: Add transaction flag (-T) support for s390 Date: Tue, 26 Jun 2018 09:17:01 +0200 X-Mailer: git-send-email 2.16.4 X-TM-AS-GCONF: 00 x-cbid: 18062607-0028-0000-0000-000002D4F2F4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18062607-0029-0000-0000-0000238C5504 Message-Id: <20180626071701.58190-1-tmricht@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-06-26_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1806260081 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 dependend json files. This requires a metric named "transaction" in the json files for the platform. Introduce new function metricgroup__has_metric() to check for the existance 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 --- --- 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 22547a490e1f..16df63e9a108 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 @@ int metricgroup__parse_groups(const struct option *opt, 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 -- 2.14.3