Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp4338196imm; Mon, 25 Jun 2018 14:02:37 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJRJL2D5zANyRv5MQiXCWbv7JBwkTmF8yblzj4X3WE/DUozpu9/gzadcJvC6FNGbH5Xucne X-Received: by 2002:a63:69c4:: with SMTP id e187-v6mr11816210pgc.294.1529960557118; Mon, 25 Jun 2018 14:02:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529960557; cv=none; d=google.com; s=arc-20160816; b=qX8pO5kagIuVcSO36xlqp+xnQC+pnrcjGtGzGqsiOavphrYNwVdqDuI1bDMJI6TaWS v0/53vcp/jpRTJYM4nB5CvanYDQbxurkK82VMpCFhLmtjwlTP+qkaGlzG579lIBXiykq lhc0jLlEuSjFR4cqMtXcovZvHfbtbalUpDzIA8MeUQ0Z07d+09H5dQ2gbEcFeQIo7APb 9t9q7qU58pfexz3ISfK8Egw8+gRSHPVn3AZB1xcIVO801z/wqZiiGzjmnesv/J6yaXM0 rH2y79+fuYQsf6ydSPgDFp4vto0wG5lDrxnbAyHIV4J8h4VElLqahnwH+ph5VEmRJe5o a6tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=10nUu/O41wbvM187QfXt+gQPzHbLLupr936vxqaOp7E=; b=XX+KJCxGHfvzjbKyTWqdHjj8yLKWKq05z7jgffN8WbFXpzq2E2yfOBQ6ouIpraWkIg oh1flX1S/p7g9GIgAa+sMSEg/yHOv3btSokbqOA+dw4V6ci6/LY1m+aTFfvJm07R0oZg k/eQyGfnhHcWKjJWS+Nl3O3AqaajMDY84WOW7lA1xBqQErvWItuNflVlMfUGFfzID1U4 n4Km/h1SBVK3M5eNcliNNYZFdbj/4Ph6DNLbxLcgHF+oq+spXa8C8ky+9XuIC0hD2MzH e/3X1zHPdTLLueVl3ojDuqVDoB4zBw5jeMfo4q2sw/+nzf/EhYPn/XiM3VDSjsQs6ECZ zLHA== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n9-v6si7354876pgd.541.2018.06.25.14.02.21; Mon, 25 Jun 2018 14:02:37 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752327AbeFYVB2 (ORCPT + 99 others); Mon, 25 Jun 2018 17:01:28 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:52152 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751556AbeFYVB0 (ORCPT ); Mon, 25 Jun 2018 17:01:26 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ACF7E81A4E9F; Mon, 25 Jun 2018 21:01:25 +0000 (UTC) Received: from krava (ovpn-204-34.brq.redhat.com [10.40.204.34]) by smtp.corp.redhat.com (Postfix) with SMTP id 6D6132026D5B; Mon, 25 Jun 2018 21:01:22 +0000 (UTC) Date: Mon, 25 Jun 2018 23:01:21 +0200 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Andi Kleen , Thomas Richter , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, brueckner@linux.vnet.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, Jiri Olsa , Namhyung Kim Subject: Re: [PATCH 4/4 v3] perf stat: Add transaction flag (-T) support for s390 Message-ID: <20180625210121.GA13952@krava> References: <20180625125856.20262-1-tmricht@linux.ibm.com> <20180625145247.GY20477@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180625145247.GY20477@kernel.org> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 25 Jun 2018 21:01:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 25 Jun 2018 21:01:25 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jolsa@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 25, 2018 at 11:52:47AM -0300, Arnaldo Carvalho de Melo wrote: > Em Mon, Jun 25, 2018 at 02:58:56PM +0200, Thomas Richter escreveu: > > 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. > > You forgot to CC Andi in this post, Andi, is everything ok now? May I > have your reviewed-by or acked-by? hu, I haven't got this one either.. will check jirka > > Thanks, > > - Arnaldo > > > v2 --> v3: > > Introduce new function metricgroup__has_metric() to check for > > the existance of a metric named 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 > > Suggested-by: Hendrik Brueckner > > Reviewed-by: Hendrik Brueckner > > --- > > tools/perf/builtin-stat.c | 12 ++++++++++++ > > tools/perf/util/metricgroup.c | 23 +++++++++++++++++++++++ > > tools/perf/util/metricgroup.h | 1 + > > 3 files changed, 36 insertions(+) > > > > diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c > > index a4f662a462c6..e309279e7b04 100644 > > --- a/tools/perf/builtin-stat.c > > +++ b/tools/perf/builtin-stat.c > > @@ -2425,6 +2425,18 @@ static int add_default_attributes(void) > > if (transaction_run) { > > struct parse_events_error errinfo; > > > > + /* 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..90cff5226ecc 100644 > > --- a/tools/perf/util/metricgroup.c > > +++ b/tools/perf/util/metricgroup.c > > @@ -490,3 +490,26 @@ 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_group, metric) || > > + 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