Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3984786imm; Mon, 25 Jun 2018 07:53:46 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJnWaix0mD8j4OY+qNoAzkN05bWZbcgV2mLU4Rc1X71OpxHK358utfvJrbTJv4/iqfNlWuv X-Received: by 2002:a62:d345:: with SMTP id q66-v6mr13446379pfg.158.1529938426068; Mon, 25 Jun 2018 07:53:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529938426; cv=none; d=google.com; s=arc-20160816; b=rP0Fodqwa3CzjoGbkGjn0Cw1F6N674rYUt/cmp54Oy4daQ8/P4Xs2V5bKcUz2Mi7He VM8hIztohtSmzmEIusYvRnu3IvQ/ZfEYrtNM7QA+WWI349936ocGMMVeukPe9cUUx0cO S8fkRJxEnTM0BDnzdbyKtYb6vLogNP/Ouc/iGb0NPZkgfECTvF3s7M+UvtLwhdjNikwy t3aXOpS8ogglv7CA9Nprnq15QJJX9JSZvne/+BLCkPIgCTlMWkaBbV+XbUzw0tdNDbWK +IrYxIVxd1p/+OUWsh0RIa9PCQYxpaP3+RDQlT5yi1w3Be4lCXhVdBGMutz2Ckj2k8Ne cz/w== 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:dkim-signature:arc-authentication-results; bh=KJpXgfcZtRza+fiLnrcjCJDxbh/cMld2PE2xHk6JRhI=; b=zOuIe7rVr5IuAP3QGG7JwdRDv6VJQ3kXluCv/AiKepj1AlpmlVLv0JuC4OUZ6jLjZR LKEf5w5CopO5ny/u83/V/ddYH/xOM8da/2YCeGyv0cmisYLeZ3kFafWHSBFwassMeMLH uZ603zbvQ9ykwbasMbsQUsx86CSlXWXASs+ZUYhqtv3LGpKwHNHOEzDjnO2swCjqqeTf UHlCpTiEw1y86znHBRf30GpmQVeQLKXNLlcThbE0d+CBtePrk2uyJY42wV3FTcSCBHui PFKflfpmtDILRVdU4frvtZdAHRXh5W2ewbAcli3PAUpmuswIznVolmzD0gjtPtPLqhQp X7Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TNNhcoRj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f35-v6si13651957plh.193.2018.06.25.07.53.31; Mon, 25 Jun 2018 07:53:46 -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; dkim=pass header.i=@kernel.org header.s=default header.b=TNNhcoRj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934483AbeFYOwx (ORCPT + 99 others); Mon, 25 Jun 2018 10:52:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:56324 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934325AbeFYOwv (ORCPT ); Mon, 25 Jun 2018 10:52:51 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CC34525BCB; Mon, 25 Jun 2018 14:52:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1529938371; bh=P9QF5kAbcoZIjVQ3d5pr2r8OPhfvq/9EytA3V5V85MY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TNNhcoRj52JsWY2/7oTWeDcidRH2vBNEURxSmuXSdRgbAk1XB0KciBSaAArHh+DA0 67WGi4LJJ7udyg8Lm1aSzyAMQzOJVi6a2d7lz4qjPHbV3Cp4BpbD0IbIQ/SX1mSuDn DLJD0q9I9sotBdshx0fWxAAIylsbh2mKTzknWDoo= Received: by jouet.infradead.org (Postfix, from userid 1000) id C6CF31401E5; Mon, 25 Jun 2018 11:52:47 -0300 (-03) Date: Mon, 25 Jun 2018 11:52:47 -0300 From: Arnaldo Carvalho de Melo To: Andi Kleen , Thomas Richter Cc: 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: <20180625145247.GY20477@kernel.org> References: <20180625125856.20262-1-tmricht@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180625125856.20262-1-tmricht@linux.ibm.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? 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